Nov 10, 2018

How to set Sendmail to listen to IP besides Local IP on Amazon EC2

First you need to edit /etc/mail/sendmail.mc, find the following section:
dnl This changes sendmail to only listen on the loopback device 127.0.0.1
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
You will need to comment out the like with DAEMON_OPTIONS, using "dnl" at the begining of the line:
dnl This changes sendmail to only listen on the loopback device 127.0.0.1
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
You will then need to rebuild the file:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

You may need to install m4 package:
yum install -y m4

Restart sendmail:
service sendmail restart

Test it ( After open port 25 for incoming traffic in your security group/firewall)
~$ telnet mail.i88.ca 25
Trying 88.88.88.88...
Connected to mail.i88.ca.
Escape character is '^]'.
220 ip-10-0-0-88.ec2.internal ESMTP Sendmail 8.14.4/8.14.4; Tue, 6 Jan 2015 02:25:16 GMT
^]

See also:

How to fix Sendmail error m4:/etc/mail/sendmail.mc:10: cannot open `/usr/share/sendmail-cf/m4/cf.m4': No such file or directory