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.
分类 Sendmail 下的文章
If you have a SMTP email server and you want to test if it is working properly, you can following the steps below to test it.
[email protected]:~$ telnet 127.0.0.1 25
Connected to 127.0.0.1.
Escape character is '^]'.
220 myhost ESMTP Sendmail 8.14.3/8.14.3/Debian-9ubuntu1; Sat, 16 Jan 2010 17:28:30 -0800; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
250 myhost Hello localhost [127.0.0.1], pleased to meet you
354 Enter mail, end with "." on a line by itself
250 2.0.0 o0H1SUjV016265 Message accepted for delivery
221 2.0.0 npu40 closing connection
Connection closed by foreign host.
If you can receive the above email properly, it means you can send email from the localhost. Next step, you can try to telnet it external IP address, like 192.168.0.123, to check if it can relay emails through the external IP address.