2

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 user@xyz.com, 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.

sebix
  • 4,313
  • 2
  • 29
  • 47
T Smith
  • 31
  • 4
  • Show your postfix log entries for this message submission. – Michael Hampton Nov 15 '15 at 09:07
  • This is what is showing in my Postfix log: Nov 16 13:40:03 postfix/smtp[6518]: 19998A1B96: to=, relay=mx2.hotmail.com[65.55.37.120]:25, delay=1.6, delays=0.09/0.01/0.49/1.1, dsn=2.0.0, status=sent (250 Queued mail for delivery) – T Smith Nov 16 '15 at 13:42

0 Answers0