I have Postfix running on a VPS with Ubuntu 12.04, the server has multiple IP addresses.
I want to configure Postfix so that it will route mail to send via one of these IP's based on the MX record of the recipient e-mail domain.
For example, if I am sending an email to [email protected], lets assume this domain uses Google's MX records (e.g. aspmx.l.google.com, aspmx2.googlemail.com). There should be a rule that says if the active MX record contains the domain google.com, then it will route to an IP which I specify.
I know that it is possible to do this if you define rules for specific domains, but I haven't found much useful information for routing based on MX records.
Someone mentioned that it should be possible to do this by using check_recipient_mx_access and to place this within smtpd_recipient_restrictions but it doesn't seem to work:
This is what I have implemented so far:
smtpd_recipient_restrictions = check_recipient_mx_access hash:/etc/postfix/mx_access,permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
I then created a file called mx_access and added the following rules:
.google.com gmail
.googlemail.com gmail
Then in master.cf, I added the following lines:
gmail unix - - - - - smtp
-o smtp_bind_address=insert_ip_here
When I sent a test email to my email address which uses gmail's mail servers, it came through from the main server IP, instead of the IP I specified.
Any help would be much appreciated.