The mailertable is a handy feature of Sendmail. Using the mailertable, it is possible to route messages for specific domains to manually specified mail servers. This is a common need, as sendmail ignores /etc/hosts when looking up mail servers. Instead, it strictly relies on dns, unless dns is overridden with the service.switch file. It is usually more desirable to use the mailertable to override the default MX lookup.
Sendmail configuration is typically located in the /etc/mail directory. The main configuration file for sendmail is sendmail.cf. sendmail.cf contains many macro instructions, some of which require specific whitespace characters to function properly. To reduce the chance of sendmail.cf configuration errors, sendmail provides the sendmail.mc file. It is recommended to use sendmail.mc to change sendmail.cf, rather than doing it directly.
The mailertable is available in sendmail.mc:
FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl
If the line is not preceded with dnl, it was probably defined by default and already available in sendmail.cf. If it is preceeded with a dnl, remove the dnl and run the command to rebuild sendmail.cf:
make -C /etc/mail
Note that the sendmail-cf must be installed for sendmail.mc and the make command to work.
sendmail.cf should now contain this line:
Kmailertable hash -o /etc/mail/mailertable.db
Create or edit the plain text version of mailertable, in the /etc/mail directory
mailertable entries can take these forms:
10.10.10 smtp:mail.tententen.com - send all mail from 10.10.10 to mail.tententen.com
example.com esmtp:[126.96.36.199] - all mail sent to example.com is forwarded to 188.8.131.52
example2.com smtp:[mail.example1.com] - all mail sent to example2.com is forwarded to mail.example1.com
It is necessary to generate a hash database from the mailertable text file
makemap hash /etc/mail/mailertable < /etc/mail/mailertable
Which creates the file /etc/mail/mailertable.db