1

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.

2
  • the newdomain.com is hosted on the same server?
    – ALex_hha
    Sep 3 '13 at 19:21
  • no... the postfix server above is the gateway to the local Exchange server for the old domain. The new domain is another mail server hosted by HQ in another city.
    – cwheeler33
    Sep 4 '13 at 13:06
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.