procmail
[Top] [All Lists]

Re: How to OR conditions

2002-05-29 07:53:21
On Wed, 29 May 2002, Olivier Nicole wrote:

      # EXCEPTION 1
      :0 :
      * ^From root
      * ^Subject: Quarantined messages
      * ^Reply-To: quarantine(_at_)cs(_dot_)ait(_dot_)ac(_dot_)th
      $DEFAULT
      
      #EXCEPTION 2
      :0 :
      * ^From root
      * ^Subject: Cron
      $DEFAULT
      
      #EXCEPTION 3    
      :0 :
      * ^From quarantine(_at_)cs(_dot_)ait(_dot_)ac(_dot_)th
      $DEFAULT
      
      :0fw
      | filter spam

So, I'd rather write:

      :0fw
      * ! EXCEPTION 1
      * ! EXCEPTION 2
      * ! EXCEPTION 3
      | filter for spam

There are a bunch of ways to do this.  One is, don't deliver when you find 
an exception, but instead set a variable, and then later test that 
variable.  E.g.:

        :0
        * ^From root
        * ^Subject: Quarantined messages
        * ^Reply-To: quarantine(_at_)cs(_dot_)ait(_dot_)ac(_dot_)th
        { EXCEPTION=1 }

        :0
        * ^From root
        * ^Subject: Cron
        { EXCEPTION=2 }

        :0
        * ^From quarantine(_at_)cs(_dot_)ait(_dot_)ac(_dot_)th
        { EXCEPTION=3 } 

        :0fw
        * ! EXCEPTION ?? [123]
        | filter spam

Another is to use if/else conditions with the E flag, and empty actions:

        :0
        * ^From root
        * ^Subject: Quarantined messages
        * ^Reply-To: quarantine(_at_)cs(_dot_)ait(_dot_)ac(_dot_)th
        { }

        :0E
        * ^From root
        * ^Subject: Cron
        { }

        :0E
        * ^From quarantine(_at_)cs(_dot_)ait(_dot_)ac(_dot_)th
        { }     

        :0Efw
        | filter spam

Another is to use scoring (see "man procmailsc"):

        :0fw
        *  3^0
        * -3^0 ^From quarantine(_at_)cs(_dot_)ait(_dot_)ac(_dot_)th
        * -1^0 ^From root
        * -2^0 ^Subject: Cron
        * -1^0 ^Subject: Quarantined messages
        * -1^0 ^Reply-To: quarantine(_at_)cs(_dot_)ait(_dot_)ac(_dot_)th
        | filter spam

There, every message starts with a score of 3, then that score is reduced
(by varying amounts) for each of the exceptions.  If it reaches zero or
less, the action will not be executed.  This isn't the best example of
scoring because you really want the three cases to be tried independently
(e.g., a message with two Subject: lines should not bypass the filter),
but it shows what sorts of things you can do.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>