Build your Sendmail Relay Server in your LAN


I installed a sendmail relay server in my LAN so that other servers can use it to send emails. The following is how I did the configuration in a Ubuntu 9 machine.

1. First you need to install sendmail package.

2. After installation, you need to do the following configuration:

(1) Sendmail Master Configuration File: /etc/mail/

# vi

To enable relay on a specific IP, you need to change SMTP Daemon's IP address. By default, it is which is your localhost loopback address. This setting only allows you to send email from localhost. If you want other servers to use this server as relay to send emails, you much change to a valid IP address in your LAN, for example, it can be In order to do so, you need to change the line 57 and 59 to as below:

DAEMON_OPTIONS('Family=inet, Name=MTA-v4, Port=smtp, Addr=')dnl
DAEMON_OPTIONS('Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=')dnl

Please replace with your real IP address. You also need to change following two lines at 100 and 104:


Next step, you need to compile the file to file which will be actually used by sendmail. You need to type:

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

You need to restart the sendmail server to make the change effective:

# /etc/init.d/sendmail restart

To check if the Sendmail is listening on an IP and a specific port, you can type:

# netstat -aunt

To check if the SMTP Port is open and listening from another server, you can type:

# nmap -v -sT (IP address of this SMTP server)

(2) Configure the Access Control file: /etc/mail/access

# vi access

If you want to allow to relay, add the following line:

Connect: RELAY

You also need to compile the access file to access.db file.

# makemap hash /etc/mail/access.db < /etc/mail/access

You need to restart the sendmail service to make it effective.

3. Sendmail Troubleshooting

If the local domain emails can not be delivered, and if your email service is hosted by an outside ISP, like Gmail (Google App.), please make sure your DNS setting will let you to resolve the correct MX record. Usually, you can set the external DNS server as your DNS server.

For example,

# vi /etc/resolv.conf


You need to replace with your real DNS Server's IP address provided by your ISP.

标签: UNIX & Linux, Sendmail, relay, lan, Ubuntu, Redhat, rhel, Fedora


  1. I actually believe this posting , “Build your Sendmail Relay Server in your LAN | Bo Wu's IT Lab”, highly engaging and it was in fact a remarkable read. Thanks for the post,Gerald