a Quick post on how to change your relayhost on Postfix to a External SMTP Provider and aswell how to revert back the changes so the Relay server sends out mail directly.
Checking your current relayhost configuration:
We will assume your /etc/postfix/main.cf
has a relayhost entry of #relayhost =
, in my example it will look like this:
1 2 |
|
If not, you can just adjust your sed command accordingly.
Changing your relayhost configuration to a External SMTP Provider:
We will use sed to change the relayhost to za-smtp-outbound-1.mimecast.co.za
for example:
1
|
|
to verify that we have set the config, look at the config:
1 2 |
|
Once you see the changes looks as expected, you can restart postfix:
1
|
|
Then you can tail the logs to see if the mail gets delivered:
1
|
|
Revert your changes so that postfix sends out directly:
To revert your changes, let’s change the config back to what it was:
1
|
|
To verify your changes:
1 2 |
|
As you can see the relayhost is commented out, meaning that the relayhost property will not be active, go ahead and restart the service for the changes to take effect:
1
|
|
Same as before, look at the logs to confirm mailflow is as expected:
1
|
|