Receiving Mail

For most MTAs (Postfix, Sendmail, etc.), the default configuration is to only allow relay email that is coming from the server. This is done for security reasons and means that while your Rails application will be able to send mail just fine, it won’t be able to receive mail. If you want to receive mail, you’ll need to make a small change in your configuration and then restart the MTA.

Postfix

Open the file /etc/postfix/main.cf in your editor and look for this section. Comment out “inet_interfaces = localhost” and uncomment “inet_interfaces = all”. Restart Postfix with ‘service postfix restart’.

# RECEIVING MAIL

# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on.  By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
# See also the proxy_interfaces parameter, for network addresses that
# are forwarded to us via a proxy or network address translator.
#
# Note: you need to stop/start Postfix when this parameter changes.
#
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost

Sendmail

Open the file /etc/mail/sendmail.mc. Look for the string “DAEMON_OPTIONS”. You will need to change the last line of this part:

dnl # The following causes sendmail to only listen on the IPv4 loopback address
dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
dnl # address restriction to accept email from the internet or intranet.
dnl #
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl

to this:
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA’)dnl

This will tell sendmail to listen on all interfaces, instead of just the loopback address (127.0.0.1).
Restart sendmail with ‘service sendmail restart’.

Meta