Adding to the answer by @joschi (and I know this is late but someone else might find this information helpful): You indicated that you only want to rewrite headers on messages for certain e-mail addresses. This is a bit tricky:
You need to set up a separate transport so that you can specify different manipulation for messages using this transport:
default location: /etc/postfix/transport
[email protected] rewriter:
[email protected] rewriter:
.anotherdomain.com rewriter:
This instructs postfix to process mails destined for these locations using the rewriter
transport. Then, in /etc/postfix/master.cf
, you can add:
rewriter unix - - - - - smtp
-o smtp_header_checks=regexp:/etc/postfix/rewrite_headers
And finally, you specify what sort of rewriting you want to actually do in the /etc/postfix/rewrite_headers
file. It has the same syntax as the default header_checks
file, it's just a custom version only valid for mails passing through the rewriter
transport.
Note, this will probably not work if you have any sort of content filter active (for example Amavis), though in my case I was running a different manipulation.