How to rewrite email subject in postfix for outgoing mail if From contains specific address?

I would like to do a simple rewrite (basically, just string replace) in the Subject line for outgoing mail, but only if there is a specific From address in the message. I looked at headers_checks, but I cannot understand how it works when you are dealing with more than one header. It would be helpful if I could process the outgoing mail using the custom script, but I can't find how to do that in postfix.

Any suggestions? Thanks!


Solution 1:

You can do it quite simply (in postfix), header_checks = regexp:/etc/postfix/header_checks is the parameter you need, then in the file /etc/postfix/header_checks add a line like this:

/^From: [email protected]/ FILTER transport:destination

the transport:destination
line is the most complicated part, the transport is a line you will define in the master.cf, and the destination is where (localhost:port, pipe, etc). You really need to read a bit of the documentation, http://www.postfix.org/FILTER_README.html and http://www.postfix.org/header_checks.5.html will give you a lot more information about how you can pass the mail to your script, as well as the control you can exert over it.