Domain – postfix+dovecot multiple domains config

domaindovecotpostfix

I'd like to setup 2 distinct mail services (that look completely separated for end-user) on one machine with 2 IP addresses and 2 domain names. I've started with my current config which is a postfix+dovecot with virtual domains/users using MySQL (it was setup some time ago with an online guide). I've added

localhost:smtp      inet  n       -       -       -       -       smtpd
<ip1 here>:smtp      inet    n       -       -       -       -       smtpd
<ip2 here>:smtp      inet    n       -       -       -       -       smtpd -o myhostname=domain2.com

so when I connect to smtp using another domain name, it has its own banner, but…

Outgoing messages are still delivered with ip address #1 which is rDNSed to domain1.com. How can I change my setup so outgoing mails from domain2.com are being delivered using ip2 interface (so email headers say Received from: domain2.com and not domain1.com)?

Best Answer

It seems that this is possible using the sender_dependent_default_transport_maps option. Have a look at this page and this.