Postfix - exclude messages with specific header values from relayhost?

Posted by Kyle MacFarlane on Server Fault See other posts from Server Fault or by Kyle MacFarlane
Published on 2011-11-17T17:13:20Z Indexed on 2011/11/17 17:55 UTC
Read the original article Hit count: 241

Filed under:

Starting with the following basic configuration to relay all messages in Postfix to PostMarkApp.com:

#start postmarkapps settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:secret:secret (where "secret is your API key")
smtp_sasl_security_options = noanonymous
relayhost = [smtp.postmarkapp.com]:25
#end postmarkapp settings

The problem with this is if for example something starts spitting our error messages they will all go through PostMark and cost money.

One way to bypass relayhost is to setup sender_dependent_relayhost_maps and have certain addresses map back to yourdomain.com. But this doesn't work in web apps where all messages are sent by the same user but with varying From headers.

So how can I achieve the same effect as sender_dependent_relayhost_maps but looking at the From or Subject headers instead of merely the user?

© Server Fault or respective owner

Related posts about postfix