Route certain domains via another relay

Proxmox Mail Gateway (PMG) routes all mails via the locally assigned IP addresses by default. This is usually only 1 IP address. Should you want to send mails in a round robin fashion using a number of IP addresses, you can follow this guide: https://base64.co.za/postfix-ip-rotation-for-proxmox-mail-gateway/.

If, for example, you want to route hotmail.com, outlook.com or live.com via another SMTP relay, you can follow this guide.

First and foremost you have to install the LibSASL module:

sudo apt install libsasl2-modules

Comment out transport_maps in /etc/pmg/templates/main.cf.in and add the following in it’s place:

transport_maps = regexp:/etc/postfix/transport.microsoft

Add the following at the bottom of that file:

# outbound relay configurations
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/pmg/sasl_passwd
smtp_sasl_security_options = noplaintext, noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000

Edit transport.microsoft with:

nano /etc/pmg/transport.microsoft

Paste the following in that file:

/.*@(outlook|hotmail|live|msn)\..*/i	relay:[smtp-relay.sendinblue.com]:587

The above simply routes outlook, hotmail, live, and msn domains via the SendInBlue SMTP relay.

Save and close that file and create the db file with the following:

postmap /etc/pmg/transport.microsoft

Create the file that will contain the authentication credentials required to use the SMTP relay (Sendinblue):

nano /etc/pmg/sasl_passwd

Paste your credentials in as follows:

[smtp-relay.sendinblue.com]:587	smtp_username:smtp_password

Save and close this file, and then generate the hash db as follows:

postmap /etc/pmg/sasl_passwd

Restart Postfix:

cd /etc/pmg/

systemctl restart postfix

Restart PMG with the new config:

pmgconfig sync --restart 1

Finally, change the permissions of the db file with the following:

chmod 0600 /etc/pmg/sasl_passwd /etc/pmg/sasl_passwd.db

You’re all done, and now all domains specified in the regex of the transport.microsoft file will be routed via the specified SMTP relay.