Linux Commands and Scripts

How To Configure Remote SMTP Server as relay

In this article, we will configure remote SMTP server as relay on CentOS 7.

If you want to configure 3rd party SMTP relay service, this article will help you. 3rd party SMTP relay service can be quick and easy alternative to setting up a full-fledged local email server.

1. Open main.cf file

# vi /etc/postfix/main.cf

2. Add a remote mail server hostname

relayhost = [smtp.server.com]

In case, SMTP server uses a different port, you need to mention it like shown below

relayhost = [smtp.server.com]:587

If you want to use multiple SMTP server for redundancy, you may configure like shown below

relayhost = [smtp1.server.com] fallback_relay = [smtp2.server.com]

This will gives you flexibility, if one SMTP relay is down, you can still send emails using second SMTP server.

In case, the SMTP server need to be configured with username and password, you can use following values:

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:postmaster@mydomain.com:password
smtp_sasl_security_options = noanonymous

3. Open /etc/postfix/mynetworks

# vi /etc/postfix/mynetworks

And add external SMTP server’s IP address like shown below:

10.0.0.25/32

10.0.0.26/32

This will let the mail server know exactly which networks are allowed to relay mail. This is a very important step

4. Restart postfix service

# systemctl restart postfix

That’s it. Now verify it by sending an email.

In this article, we have seen how our support engineers configure remote SMTP server as relay on CentOS 7.

[Need assistance to fix this error or install tools? We’ll help you.]

Related Articles