Need help with rule set

Jules Field MailScanner at ecs.soton.ac.uk
Wed Jul 29 16:42:00 IST 2009



On 29/07/2009 15:55, Mark Sapiro wrote:
> MailScanner 4.78.2
>
> I have a ruleset for "Notices To" like the following
>
> To: /^postmaster(\+.*)?[@.]example\.(net|org)$/ address1
> To: /[@.]example\.(net|org)$/ and To: !/^postmaster/ address2
> FromOrTo: default address3
>
> The intent is to send virus notices for mail sent to the postmaster
> address in the example.net and example.com domains to address1; to
> send notices for mail sent to other addresses in the example.(com|net)
> domains to address2, and to send notices for mail to other domains to
> address3.
>
> The first rule works fine. A notice for mail sent to
> postmaster at example.net is sent to address1.
>
> The problem is that a notice for mail to user at example.net is sent to
> the default address3 instead of address2.
>
> Does !/regexp/ work the way I've used it here? Is there something wrong
> with what I'm doing?
>    
That's not allowed.
> Note that if the second rule is just
>
> To: /[@.]example\.(net|org)$/ address2
>
> Then notices for postmaster at example.net mail get sent to both address1
> and address2 which is expected for an "all match" ruleset, but not
> what I want. I really want to say
>
> To: /[@.]example\.(net|org)$/ and NOT To: /^postmaster/ address2
>
> and I thought
>
> To: /[@.]example\.(net|org)$/ and To: !/^postmaster/ address2
>
> would do it, but it doesn't seem to. It appears that I can do this with
> a negative lookahead regexp as in
>
> To: /[@.]example\.(net|org)$/ and To: /^(?!postmaster)/ address2
>
> but in a more complex case the ability to say "doesn't match regexp"
> without using negative lookahead seems useful.
>
>    
A simple of phrasing pretty much the same thing would be this:

To: postmaster at example.net address1
To: postmaster at example.org address1
To: *@example.net address2
To: *@example.org address2
FromOrTo: default address3

That will also work a whole lot faster, as it can be implemented as a 
single hash lookup rather than having to evaluate all the regexps each time.

The only problem I can see you might hit is that "NoticeRecipient" is 
listed in ConfigDefs.pl in the "[All,Other]" section, where you might 
want to move it to the "[First,Other]" section, or else notices to 
postmaster at example.net and org will probably end up at address1 and 
address2. If that's particularly important to you, of course, which it 
may well not be really.

If you really want to catch notices to any address starting with 
"postmaster", then you could use
To: postmaster*@example.net address1
syntax instead.

Keep it simple, and easy to understand, and you will find it works a lot 
faster. The configuration engine is optimised for the sort of rules that 
mortals understand, it's not optimised for horrendously complex regexps.

Jules

-- 
Julian Field MEng CITP CEng
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store

Need help customising MailScanner?
Contact me!
Need help fixing or optimising your systems?
Contact me!
Need help getting you started solving new requirements from your boss?
Contact me!

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
Follow me at twitter.com/JulesFM and twitter.com/MailScanner


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the MailScanner mailing list