Sendmail Smarthost

Introduction

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

Overview

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.

Configuration

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

Prerequisites

You should have sendmail 8.11 or above installed.

Configuring sendmail

Sendmail should be configured to include the following directives:

define(`SMART_HOST',`[smarthost.example.net]')dnl

Generate the sendmail.cf file. Refer to our configuration guide for instructions to generate a sendmail.cf 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 sendmail.cf should be generated, for sendmail to rewrite the sender's address:

FEATURE(masquerade_envelope)dnl
FEATURE(`genericstable')
GENERICS_DOMAIN(`host.example')

Create a /etc/mail/genericstable file

Add the following entries:

root <TAB> user@example.net

root@host.example <TAB> user@example.net

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 user@example.net.

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 smarthost-submit.mc 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.

Feedback

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

http://www.elandsys.com/resources/sendmail/smarthost.html