When sending an email to a recipient in an external domain, such as @hotmail.com, the email must be routed over the Internet. By default, some external domains will refuse emails that are sent from a server that has a dynamic IP address. In this example, when attempting to send an email to firstname.lastname@example.org, the Postfix email logs identify that Hotmail refused the email because the email was sent from a server with a dynamic IP address.
[root@server1 ~]# tail /var/log/maillog Aug 16 10:05:49 example postfix/smtp: 894C4BA14E8: to=, relay=mx1.hotmail.com[22.214.171.124]:25, delay=119, delays=117/0.03/2.2/0.25, dsn=5.0.0, status=bounced (host mx1.hotmail.com[126.96.36.199] said: 550 DY-001 (SNT004-MC1F35) Unfortunately, messages from 188.8.131.52 were not sent. Please contact your Internet service provider. You can tell them that Hotmail does not relay dynamically-assigned IP ranges. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors. (in reply to MAIL FROM command))
Relaying emails through a third party resolves this issue.
Typically, you will relay emails through:
Following are a few examples of how to configure the /etc/postfix/main.cf file to relay an email through a trusted third party.
relayhost = [mail.twc.com]:587 #Time Warner Cable ISP relayhost = [smtp.godaddy.com]:587 #Go Daddy registrar relayhost = [smtp.1and1.com]:587 #1and1 registrar
Some ISPs will provide email relay, some will not. Some registrars will provide email relay for free, some will charge to use the relay. You will need to consult with your ISP or registrar to determine if they provide an email relay service and if there is a cost to relay emails. Once you have selected an ISP or registrar to relay emails through, you will need the following information:
Create the sasl_passwd file:
~]# touch /etc/postfix/sasl_passwd
Add the following line to the sasl_passwd file:
Create the sasl_passwd.db file:
~]# postmap /etc/postfix/sasl_passwd
The username and password in the sasl_passwd and sasl_passwd.db files are in plaintext, so we should ensure that only root and read and write these files.
~]# chown root:root /etc/postfix/sasl_passwd ~]# chown root:root /etc/postfix/sasl_passwd.db ~]# chmod 600 /etc/postfix/sasl_passwd ~]# chmod 600 /etc/postfix/sasl_passwd.db
The strings command can be used to confirm that the sasl_passwd.db files was updated to contain your username and password.
~]# strings /etc/postfix/sasl_passwd.db username:password [smtp.example.com]:587
The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.
If your system is using systemd, use the systemctl command to start and enable postfix.
systemctl restart postfix systemctl status postfix
If your system is using init, use the service command to start and enable postfix.
service postfix restart service postfix status
Send an email:
View the journal to ensure the email was successfully sent. In this example, the journal is checked for an email sent to email@example.com, and the status of the email is sent.
~]# journalctl | grep firstname.lastname@example.org May 12 19:59:10 mail.example.com postfix/smtp: E56D660173: to=<email@example.com>, relay=mail.twc.com[184.108.40.206]:587, delay=21, delays=20/0.13/0.24/0.24, dsn=2.0.0, status=sent (250 2.0.0 OK FC/59-29375-E5A56195)