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!


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: user@domain.com/ 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.

| improve this answer | |

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.