Sendmail Smarthost


A smarthost is a host through which outgoing mail is relayed.


Some ISPs block outgoing SMTP traffic (port 25) and require their users to send out all mail through the ISP's mail server. Sendmail can be configured to use the ISP's mail server as the smart host.


The following installation guide is based upon sendmail 8.11 about above.


You should have sendmail 8.11 or above installed.

Configuring sendmail

Sendmail should be configured to include the following directives:


Generate the file. Refer to our configuration guide for instructions to generate a file.

The following sample configuration files are available for download. For the smarthost sample configuration, you should change the OSTYPE() setting to the one for your operating system. The my_isp_smtp setting should be changed to the hostname of your ISP's SMTP server.

Restart sendmail for the new configuration to take effect.

Rewriting the sender's address

If your server's hostname does not resolve in DNS, your email may be rejected by mail servers which have antispam measures enabled. Sendmail returns the following error:

553 5.1.8 <user@host.example>... Domain of sender address user@host.example does not exist

You can use the genericstable feature of sendmail to rewrite the sender's address. The following entries should be included in your .mc file, and a new should be generated, for sendmail to rewrite the sender's address:


Create a /etc/mail/genericstable file

Add the following entries:

root <TAB>

root@host.example <TAB>

Then type:

makemap hash /etc/mail/genericstable < /etc/mail/genericstable

In the above example, mail with a sender's address of root will be rewritten to

Sending mail through to a different ISP

If you wish to submit mail through a different ISP and that ISP supports mail submission over port 587, download the file and follow the configuration instructions mentioned above.

It is good practice to submit mail through port 587 instead of port 25 as that port has been assigned for mail submission.


If you have any comments, you can contact the author here.