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/sendmail.mc
# vi sendmail.mc
To enable relay on a specific IP, you need to change SMTP Daemon's IP address. By default, it is 127.0.0.1 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 192.168.0.88. 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=192.168.0.88')dnl
DAEMON_OPTIONS('Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=192.168.0.88')dnl
Please replace 192.168.0.88 with your real IP address. You also need to change following two lines at 100 and 104:
Next step, you need to compile the sendmail.mc file to sendmail.cf file which will be actually used by sendmail. You need to type:
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
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 192.168.10.10 (IP address of this SMTP server)
(2) Configure the Access Control file: /etc/mail/access
# vi access
If you want to allow 192.168.0.99 to relay, add the following line:
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.
# vi /etc/resolv.conf
You need to replace 22.214.171.124 with your real DNS Server's IP address provided by your ISP.