How to route mail in Postifix based on recipient address

postfix

I have built a Spam filter based on this RECIPE

Since then my requirements have changed and would like to know how to route mail in Postfix based on the recipient email address. Some users now belong to a new domain and are hosted on another mail server but I do not want to lose mail that is sent to their old address.

So if I receive:

  • user01@olddomain.com it forward to the old mail server with the same address
  • user02@olddomain.com it forward to user2@newdomain.com
  • user03@olddomain.com it drops without NDR because it is not listed in "relay_recipient_maps"

When I tried to simply add the following to /etc/postfix/virtual the test message seemed to just get lost somewhere. I have no clue where it went or how to check where it went…

user02@olddomain.com user2@newdomain.com

Many thanks for any pointers.

Best Answer

You can use transport_maps

relay_domains = olddomain.com, newdomain.com
transport_maps = /etc/postfix/relay_maps
recipient_canonical_maps = hash:/etc/postfix/recipient_canonical

/etc/postfix/relay_maps

user01@olddomain.com smtp:[ip.of.local.exchange]
user02@olddomain.com smtp:mx.newdomain.com
user03@olddomain.com no-reply

/etc/aliases

no-reply: /dev/null

/etc/postfix/recipient_canonical

user02@olddomain.com user02@newdomain.com

Note: you must create local user no-reply

Related Topic