Force sendmail to route mail to specific hosts or mailserver

Posted: September 14, 2008 in LINUX
Tags: ,

mailertable allows you to route or deliver mail to different hosts. You need to use feature called FEATURE(`mailertable’) and you will have to create an external database containing the routing information for various domains.

First include mailertable feature you need to edit your file and add the following line:

Open sendmail config file using text editor:

# vi /etc/mail/

Append/modify line as follows:


Regenerate sendmail configuration file using m4:

m4 /etc/mail/ > /etc/mail/

Restart sendmail service:

# /etc/init.d/sendmail restart

Open /etc/mail/mailertable file and add domain name to route to different hosts. For example all mail coming from network 192.168 route to and all email for will be automatically forwarded to a mail server

# vi /etc/mail/mailertable

Append following lines:


Now build database version of the mailertable is built using:

# makemap hash /etc/mail/mailertable Or just type make command to build new mailertable.db file:
# make 

  1. […] You could try blacklisting all outgoing destinations except for those listed in a whitelist. Or, you could try forcing sendmail to send mail to specific hosts as described in this article:…or-mailserver/ […]

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s