 |
Using 'mailertable' in Sendmail
added 10.24.2001 -- written by David van Geyn
|
Article Description: This article describes how to set up 'mailertable' in Sendmail. This sendmail option allows you to specify destination servers for specific mail domains (great for acting as a second MX host). This is better for mail routing than virtusertable.
While 'virtusertable' has its place (and that is as an alternative to using mail aliases), it should not be used to route mail according to domain. This is where 'mailertable' comes in to play.
Preface
First, a bit of a preface. When I was first acting as a secondary MX host for a friend's domain, I just set up my 'virtusertable' like so:
%1@friendsdomain.com %1@mx1.friendsdomain.com
Now, while this does work, when looking at the mail headers of any message processed this way, the destination actually gets rewritten as @mx1.friendsdomain.com.
'mailertable' avoids this all together. What 'mailertable' allows you to do is route mail to specific servers (in this case mx1.friendsdomain.com) without having the destination rewritten.
Setting up 'mailertable'
To set up 'mailertable', you need to edit your sendmail .mc file and add the following line:
FEATURE(`mailertable')
After doing this, you need to using the script supplied with the Sendmail source to rebuild your configuration file.
Now, open your new Sendmail configuration file and look for this (it should be in the first couple hundred lines of the file):
Kmailertable hash /etc/mail/mailertable
This defines where the 'mailertable' file should be, and in this case it is in /etc/mail.
Now let's go back to my previous example of being a secondary MX host for friendsdomain.com. If I wanted to do this with 'mailertable', I could add the following line to my /etc/mail/mailertable:
friendsdomain.com smtp:[mx1.friendsdomain.com]
After editing this file, you must create a database map of this file for Sendmail to read. Do this by running:
/usr/sbin/makemap hash /etc/mail/mailertable.db < /etc/mail/mailertable
Now all that's left to be a secondary MX host for friendsdomain.com is to add the domain to your relay domains file. In my case, that file is /etc/mail/relay-domains. Add the following line:
friendsdomain.com
Now if you restart sendmail, and telnet to your system on port 25 (sendmail port), and execute the following:
EHLO mail
MAIL FROM: your@email.com
RCPT TO: you@friendsdomain.com
DATA
Hi there
.
QUIT
That message should be routed according to your 'mailertable', in this case to mx1.friendsdomain.com.
If you have any suggestions about this article, please send feedback.
NOTE ADDED October 4, 2002
The following is a comment from an e-mail sent to me by a visitor of the site.
I received an e-mail from a visitor indicating that even though they'd added the proper things to 'sendmail.cf' and mailertable, the mail was still being delivered locally. The solution to this problem was to remove the domain that was supposed to be forwarded from the 'local-host-names' file and add it instead to the 'relay-domains' file.
|
|
|
 |