we needed quick solution to redirect all mails from development box to go to one address no matter what address was in the rcpt filed to test some mail sending program without affecting the users in question.
It turned out that this is much easier than expected and requires only 2 steps with postfix:
- is to create a map file f.e. /etc/postfix/redirect_map containing one line:
/./ admin@webangel.ie
this would rewrite any address passing through this mail server to admin@webangel.ie
- the second thing is to tell postfix to use this map file for rewritting:
recipient_canonical_classes = envelope_recipient
recipient_canonical_maps = regexp:/etc/postfix/redirect_map
of course that being based on regexp have whole lot more possibilities but it did what we needed.