I am trying to filter all outgoing mail based upon the "to" header. We use a relay for all outgoing mail. I think using header_checks is the best way, but I cannot get that to work. Is the following header check correct?
!/[Tt][Oo].*@ourdomain\.com/ DISCARD not being sent to ourdomain.com
I am attempting to discard all mail that isn't sent to an email addressing ending in "@ourdomain.com"
I haven't been able to get it work. No matter what gets sent, it discards it. I think this is due to the fact that the header_checks does it line by line, not the entire header. This means that it first checks the main header (i.e. received: by r110.ourdomain.com (Postfix, from userid 518)??id 5AA935C60233; Fri, 11 Feb 2011 17:48:55 -0500 (EST)), to field (i.e. To: email@example.com), etc...
I believe it's rejecting all mail because it first checks out the top header by itself, sees that it doesn't contain @mydomain.com and rejects it right then and there. Is there a way to limit the header checks to the "To" field?
The following provides me with the information leading me to believe that it's getting hung up on the top header, as well as I've checked the logs and I see it checking the top header and then rejecting mail.
Empty lines never match, because some map types mis-behave
when given a zero-length search string. This limitation
may be removed for regular expression tables in a future
Many people overlook the main limitations of header and
o These rules operate on one logical message header
or one body line at a time. A decision made for one
line is not carried over to the next line.