Problem with user-specific filename rules

Mark Sapiro mark at msapiro.net
Fri Apr 22 16:20:07 UTC 2016


On 04/22/2016 03:44 AM, Garry Glendown wrote:
>>
> I tried to, but somehow this caused all mail to be sent through the
> default rule... here's the setup I had entered:
> 
> #  Block more securely for mails to internal users
> From:   /^?!theuser at domain.de$/ and To: @domain.de           
> /etc/MailScanner/filename.rules.conf
> From:   /^?!theuser at domain.de$/ and To: @domain.de              
> /etc/MailScanner/filename.rules.conf
> 
> # Default - Somewhat less secure, allowing e.g. .docm etc.
> To:     default         /etc/MailScanner/filename.toexternal-rules.conf
> 
> As a result, all mails were let through using the more relaxed rules
> set. I tried altering the regexp pattern based on doing some tests,
> changing it to e.g. /^(?!(theuser at domain.de))$/ (which at least was
> accepted by the regexp tester I used), but it still didn't seem to match
> any sender ... am I missing something here?


Sorry, my mistake. The negative lookahead needs to be in parens as in
your last example. Also, there is an issue because the negative
lookahead doesn't consume any of the string. Thus your pattern
/^(?!(theuser at domain.de))$/ will only match the null string because it
says match the beginning of the string not followed by
theuser at domain.de, but immediately followed by the end of the string.

What you want is

From: /^(?!theuser at domain.de$)/ and To: @domain.de
/etc/MailScanner/filename.rules.conf

or perhaps

From: /^(?!(theuser|otheruser)@domain.de$)/ and To: @domain.de
/etc/MailScanner/filename.rules.conf

You need to have the '$' end of string be part of the lookahead pattern.

Sorry for the confusion
-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan


More information about the MailScanner mailing list