redirect all mails to one address on postfix

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:

  1. is to create a map file f.e. /etc/postfix/redirect_map containing one line:


    this would rewrite any address passing through this mail server to

  2. 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.