procmail
[Top] [All Lists]

Re: Is there a option to OR the conditions instead of AND

1997-08-08 21:06:00
    > if have a number of recipes something like this:
    > 
    > -----
    > :0
    > * ^From.*peter
    > $BIGMAILBOX
    > 
    > :0
    > * ^From.*alex
    > $BIGMAILBOX
    > 
    > :0
    > * ^From.*erwin
    > $BIGMAILBOX
    > ----
    > 
    > All to the same mailbox. 
    > Does an option exist to change the above recipe into this ?
    > 
    > :0
    > * ^From.*peter
    > * ^From.*alex
    > * ^From.*erwin
    > $BIGMAILBOX
    > 
    > Or is there another way to solve this.

As others have pointed out, you can use De Morgan's theorem:

   A or B  <==> ! (!A and !B )

you can use regexp alternations, like this:

    :0
    * ^From.*(peter|alex|erwin)
    $BIGMAILBOX

regexps work even for complex, completely unrelated headers:

    :0
    * (^Subject: FREE MONEY|\
       ^From: .*Spamdex.com|\
       ^To: a-big-mailing-list-I-dont-like\|
       ^X-Organization: spam-central)
    $BIGMAILBOX

But, you can also use weighted scoring to form an OR condition.

    :0
    * 1^0 ^From.*peter
    * 1^0 ^From.*alex
    * 1^0 ^From.*erwin
    $BIGMAILBOX

and showing an alternative of the complex one:

    :0
    * 1^0 ^Subject: FREE MONEY
    * 1^0 ^From:.*Spamdex.com
    * 1^0 ^To:.*a-big-mailing-list-I-dont-like
    * 1^0 ^X-Organization:.*spam-central
    $BIGMAILBOX

Please read the man page on "procmailsc" for detailed explanations of
weighted scoring.

Good luck
___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks