So, basically, you have something like:
Mail send by your i-MSCP postfix:
Response from the relay:
Well, is the relay configured to accept to relay mail from your Postfix server? Basically put, there are two schools here:
- The relay server should accept to relay mails coming from your i-MSCP Postfix server without SASL authentication. This is done by accepting to relay any mail from your i-MSP postfix server IP addresse. I don't recommend that method unless the relay server is on the same network. Also, this is not based on sender domain... and thus, that don't fit with your requirements unless if you setup proper transport map on i-MSCP postfix server.
- You provide an SASL authentication sender map for various relays. This is what you tried to do. See https://gist.github.com/zmwangx/2c56aa32be68daf48c2f for more details.
First option has to be applied on relay server side while second option has to be applied on i-MSCP postfix server side.
Finally, with the second option, you should have something like:
/etc/postfix/main.cf
- # sender-dependent sasl authentication
- smtp_sender_dependent_authentication = yes
- sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
- # Default relayhost setting
- # Must be left empty
- relayhost =
- # SMTP client authentication settings
- # This assume that the relay servers accept SASL authentication
- # throught TLS
- smtp_sasl_auth_enable = yes
- smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
- smtp_sasl_security_options = noanonymous
- smtp_sasl_mechanism_filter = plain
- smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
- smtp_use_tls = yes
- smtp_tls_security_level = encrypt
/etc/postfix/sasl_passwd:
/etc/postfix/sender_relay:
Note that with the above configuration, the service mail accounts must exist in their respective relay, with a working SALS authentication. Then the i-MSCP Postfix server will select the relay according the sender domain, authenticate using the provided service mail account, and because that mail account is allowed to send mail from the relay, this should works as expected.
Note also the use of port 587 instead of default port 25. Port 587 is more appropriate there. It is the submission port. When Postfix send mail to the relay servers, it acts like a mail client.