Configuring Postfix as a Mail Relay on CentOS 7

Generally, Postfix will already be installed on a CentOS 7.x machine as the default MTA however it along with a few additional packages will need to be installed if you wish to use Postfix as a mail relay server.

As root or sudo run the following command.

yum install postfix mailx cyrus-sasl-plain

In our case, we are relaying our internal mail to an external mail relay that requires authentication.  We need Postfix to know what user and password to use for authentication with the following command.

echo "    smtp_user:smtp_passwd" > /etc/postfix/sasl_passwd

To hash the authentication file so that it is not stored in clear text use the following command.

postmap hash:/etc/postfix/sasl_passwd

Add the following to the bottom of the /etc/postfix/ file.

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
relayhost =
mynetworks = 
inet_interfaces = all

Restart Postfix.

systemctl restart postfix

Test to make sure all is working by running the following.


Fill in the subject as you desire and <enter>.  Type something into the body of your message and <enter>.  Type “.” And <enter>.

* Make sure all firewalls allow port tcp-25 traffic.

jhudgins has written 31 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>