On 13 Nov 2013, at 6:39, Stan Hoeppner wrote:

On 11/13/2013 2:34 AM, naser sonbaty wrote:
Hi,

I need help with postfix regexp in header_checks.
I want discard all emails(any domain) from admin@

I use following:
/^(To|From|Cc|Reply-To): admin@(.*)/        DISCARD

but its not working

Tests fine here:

$ cat test.regexp
/^(To|From|Cc|Reply-To): admin@(.*)/        DISCARD

$ postmap -q "blah: ad...@abc.com" regexp:./test.regexp

$ postmap -q "From: ad...@abc.com" regexp:./test.regexp
DISCARD

$ postmap -q "To: ad...@abc.com" regexp:./test.regexp
DISCARD

$ postmap -q "CC: ad...@abc.com" regexp:./test.regexp
DISCARD

$ postmap -q "Reply-To: ad...@abc.com" regexp:./test.regexp
DISCARD

If these tests work but header_checks isn't working then you need to
execute "postfix reload" to load your new/modified regexp table.

Also, note that the carat (^) anchor isn't necessary. The header fields
you're testing for are in the left most position.  Thus no reason to
left anchor your expression.

There absolutely ARE reasons to anchor RE's in header_checks:

1. Performance. In recent years email has developed a sort of header cancer: new, often proprietary, and often opaque headers that routinely have logical lengths of hundreds of characters. Not anchoring a header check to the start of the header when you only want to check a few specific headers wastes effort scanning for a match anywhere in a header, potentially taking hundreds of times longer to confirm a non-match

2. Matching unanticipated headers. Except for the very few headers with tightly defined structure (e.g. Date), *ANY* header could potentially include any string that would match "(To|From|Cc|Reply-To): " starting somewhere other than the start of the line. e.g. "Subject: I'm naive enough to think I want to discard all mail with To: admin@ in a header"

Reply via email to