virtual_alias_domains - how to use different IP addresses when forwarding mail?

I see two solutions here.

  1. (i did configuration like this many years ago) google use many ip's as MX. You can define in transport map, that first mail is routed via gmail-smtp-in.l.google.com., and second via alt1.gmail-smtp-in.l.google.com. Then - using iptables and nat/POSTROUTING - nat connections to first google MX via first ip, and to second google MX via second ip.

  2. (not tested, but should work) ip used for outgoing mail is defined via smtp_bind_address. you can define second (and next) smtp transport in master.cf like:

smtp-1 unix  -  -   n       -       -       smtp -o smtp_bind_address=firstip
smtp-2 unix  -  -   n       -       -       smtp -o smtp_bind_address=secondip

and then define in transport map something like:

[email protected] smtp-1:
[email protected] smtp-2:

you must specify using transportmap file in main.cf file:

transport_maps = hash:/etc/mail/transport

and run

postmap /etc/mail/transport

to create hash map of it.