procmail
[Top] [All Lists]

Re: regarding OR's on multiple lines

2008-06-16 12:47:08
At 11:27 2008-06-16 -0500, TLD Procmail wrote:
* H ?? ^Subject:.*(phrase1|phrase2|phrase3)    OR

FTR, without any special flags in the flags line, the default is to match against the headers, so the "H ?? " prefix needn't be on your conditions.

You want to read "man procmailsc" which covers SCORING.

:0:
* ! ^TO_tld\(_dot_)procmail(_at_)stimulacra\(_dot_)com
* ! ^From:.*stimulacra\.com
* 9876543210^0 ^Subject:.*(phrase1|phrase2|phrase3)
* 9876543210^0 ^Subject:.*(phrase4|phrase5|phrase6)
* 9876543210^0 ^Subject:.*(phrase7|phrase8|phrase9)
ACTION

The first two conditions would both have to me met - NOT to your specific address and not From that domain (of sorts - perhaps you should include the @, or a dot?)

The next all use "maximal scoring" - anything over 2^31 power will match on its own and not require the evaluation of any of the other _scoring_ conditions (non scoring conditions must all evaluate true however). The 9876543210 value is just an easy way to represent a maximal score. If you want all the individual condition matches to be evaluated (and possibly logged), then use a simple 1^1 scoring - each scored condition will be evaluated. As long as the end score is >0, the scoring part of the conditions will evaluate as true. A NEGATIVE maximal score acts just as a positive one - it will bypass evaluating the remaining scoring and apply a FALSE result to the condition evaluation.

Of course, all those phrases you have on three separate condition lines could be continued in a single condition, wherein you are simply making use of the regexp OR operator:

* 9876543210^0 ^Subject:.*(phrase1|phrase2|phrase3|\
                phrase4|phrase5|phrase6|\
                phrase7|phrase8|phrase9)

(or just one honkin' long line, your choice)


Another thing to consider - set VARIABLES earlier in your recipe that stipulate if your address was a cleartext recipient, or if the message appeared to originate from your domain (which could include messageid and received: header checks). Later, when you have a recipe which depends upon these conditions, you can simply check the variables:

:0:
* LOCALORIGINATION ?? ^^Y^^
* CLEARTEXTRECIPIENT ?? ^^Y^^
* other conditions
ACTION


Doing this makes the individual recipes wholly generic -- if later you add another email address or change your domain, or whatever, you're changing the recipes which set the variables, but not having to make changes everywhere.

There are also the E/e and A/a recipe flags - which provide for Else and And chaining of actions.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail