Tuesday, February 16, 2010

Sendmail: How to setup Sendmail Client?

I've central e-mail server. Other servers does not need to operate as a mail server. How do I configure Sendmail as submission-only e-mail server (mail client) under CentOS / Fedora / RHEL / Debian Linux / UNIX like operating systems?

Sendmail or any MTA can work in two different modes. It can accept incoming SMTP e-mail requests and send mail from the local machine / workstation or server (cluster node). This is called outbound MTA and it always runes in a queue-only mode.

Step # 1: Disable Sendmail Daemon In a Listing Mode


Edit the file /etc/sysconfig/sendmail using the text editor such as vi, enter:

# vi /etc/sysconfig/sendmail

Modify the line:

DAEMON=no

Save and close the file.

Setting DAEMON=no tells Sendmail to execute only the queue runner on this machine, and never to receive SMTP mail requests on port # 25.

Step #2: Configure Mail Submission

You need to tell sedmail about a central MTA which will accept mail on port # 25 for all your domains. For e.g. mail.nixcraft.net act as a central MTA. Edit /etc/mail/submit.cf, enter:

# vi /etc/mail/submit.cf

Find the line beginning with D{MTAHost}, and update it to read as follows:

D{MTAHost}mail.nixcraft.net

Save and close the file. mail.nixcraft.net is the hostname of the server to which this machine should forward its all outgoing mail. Please note that mail.nixcraft.net must be configured to accept mail from your other workstations or server. Once done reload sendmail.

Sendmail Relaying : Understanding what's the Relaying all about?

My Overall architectural setup resembles as shown below:

langille.org [NEW DOMAIN] <=== freebsddiary[MAIL SERVER] <== INTERNET <== fred.logic.com[ ANY FOREIGN CLIENT]


I use langille.org as an example domain.
Just registered this domain few days back.
My Mail server is freebsddiary.

As of now my sendmail doesnt know about that domain.
I will have to tell the server about this new domain.

My Mail server doesn't accept incoming mail for that domain(langile.org).However may mail is registered as the mail host for that domain.

Type the following command :

host langille.org

langille.org mail is handled (pri=5) by freebsddiary.yi.org

If someone tried to send mail to langille.org, it will arrive at freebsddiary.org(my mail server) but it will be refused.


Logs will report:

Oct 30 11:04:44 ducky sendmail[98224]: LAA98224: ruleset=check_rcpt,
arg1=, relay=mta1-rme.xtra.co.nz [203.96.92.1], reject=550
... Relaying denied
Oct 30 11:04:44 ducky sendmail[98224]: LAA98224: from=, SIZE=938,
class=0, pri=0, nrcpts=0, proto=ESMTP,
relay=mta1-rme.xtra.co.nz [203.96.92.1]


Note that above example represents mail being sent to langille.org from an external domain. It is incoming mail.

To allow sendmail to receive mail for langille.org, I added the following entry to

/etc/mail/sendmail.cw (after sendmail version 8.10, this file is local-host-names).

langille.org

Then I told sendmail to re-read it's configuration files by issuing the following commands.

# killall -hup sendmail

Example:

Your friend's domain is retch.org. You wish to allow your friend to use your mail server. The box he will be sending mail from is dry.retch.org.

You would add the following entries to the files on your mail server:

File: /etc/mail/relay-domains

dry.retch.org

The above tells your mail server to accept outgoing mail from the host dry.retch.org.

File: /etc/mail/sendmail.cw

retch.org

The above tells your mail server to accept incoming mail for the domain retch.org (after sendmail version 8.10, this file is local-host-names).

Final Conclusion:

/etc/mail/relay-domains contains a list of hosts which are allowed to relay mail through your mail server. This list may consist of either specific hosts or whole domains.

/etc/mail/sendmail.cw (after sendmail version 8.10, this file is local-host-names) contains a list of domains for which your mail server will accept mail. This list is usually the domains hosted by your machine.