Sending an outgoing email through a 3rd party SMTP relay service is a quick and easy alternative to setting up a full-fledged local email server.
Open /etc/postfix/main.cf and add the remote mail server hostname to end of the file:
relayhost = [remote.server.com]
If the remote system uses a different port number, please specify the port number:
relayhost = [remote.server.com]:587
In some situations, for redundancy, you may want to configure the relay via two or more remote SMTP server. In such instances, you may configure the following;
relayhost = [remote1.server.com] fallback_relay = [remote2.server.com]
This gives us redundancy in a way so that if one of the SMTP relays is down, we can send emails out via the second one.
smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:firstname.lastname@example.org:password smtp_sasl_security_options = noanonymous
Now, open /etc/postfix/mynetworks and the public IP of the remote mail server. For example,
This will let the mail server know exactly which networks are allowed to relay mail. This is a very important step
service restart postfix
* Don't forget that remote mail servers need to have a valid SPF record and to be properly configured.