Sendmail Configuration - Relevent details

June 11, 2005
Sendmail is configured by editing the sendmail.mc file and then using the m4 program to write the contents to the sendmail.cf file. In the previous post, I had explained the working of sendmail in general as well as the configuration files used in sendmail.
Here I will list some of the configuration details of the sendmail.mc file.
For inserting comments in the file, you precede the line with 'dnl' - which literally means Delete-characters-to-NewLine. The file sendmail.mc is liberally commented and is very easy to follow.

Often, clients do not accept incoming mail themselves. A central mail server accepts all incoming mail and relays all outgoing mail. Client workstations "masquerade" as that mail server or as the domain (which has an appropriate MX record). This can be set up on the client by adding a few lines to the sendmail.mc file and regenerating the sendmail.cf file.
To forward all incoming mail to the central mail server - say mail.centralserver.com , uncomment the following line:
define('MAIL_HUB', 'mail.centralserver.com') dnl
Note : Central mail server's /etc/mail/local-host-names file must include the name of the host to which the incoming mail is addressed for this to work.

To deliver local mail locally but relay outgoing mail through mail.centralserver.com, set :
define('SMART_HOST','mail.centralserver.com') dnl
Note: The central mail server must allow the client host to relay through it (usually by setting up the server's /etc/mail/access file ) for this to work.

To masquerade addresses so that mail sent by a user at your host looks like it actually came from user@centralserver.com, set:
MASQUERADE_AS(`centralserver.com') dnl
FEATURE('allmasquerade') dnl
FEATURE('masquerade_envelope') dnl
It is often a good idea to not masquerade mail sent by certain users on your host - eg: root, postmaster and mailer-daemon. You can set this up with EXPOSED_USER directives:
EXPOSED_USER('root')dnl
To reduce spam on your machine:
FEATURE('dnsbl') dnl
The above line is used to check a DNS based blackhole list to reject connections from known spammers. By default, it points at a subscription service run by MAPS, but can take an argument to point at other blackhole lists. The above line can be specified several times to point to multiple lists. This feature is not enabled by default.
FEATURE('relay_based_on_MX') dnl
Automatically allows relaying if sendmail server is listed as the target domain's MX record.

Suppose you want to block mail destined for certain recipients; this can be achieved by uncommenting the following line:
FEATURE('blacklist_recipients') dnl
From now onwards, all entries listed in the /etc/mail/access file that has a REJECT or returns an ERROR code will be a blacklisted recipient. Enabled by default in sendmail.

If you want to receive mail from outside sources (disabled by default) then you have to comment out the following line:
dnl DAEMON_OPTIONS('Port=smtp,Addr=127.0.0.1, Name=MTA') dnl
This removes the loopback restriction to accept email from internet or intranet.

These are only a few important configuration details. There are lots more which you can find in the sendmail.mc file. Usually sendmail starts working out of the box. Which means, you just install it and it starts working right away. And you only need to configure it if you need certain features like those listed above.

1 comments:

  • How about several SMART_HOSTs? If one is down we have backup, sendmail documentation isn't very helpful.