procmail
[Top] [All Lists]

Re: counting and limiting emails

1996-10-24 18:40:33
Alan Stebbens suggested to Danielle Leblanc,

| There are two ways to count things in procmail recpies: using "test" or
| using weighted scoring techniques.  The first is easy, but involves
| extra processes, the latter is more efficient but I can never remember
| the technique (and thus never use it, and thus don't know it :^}).
| David Tamkin will be able to remind us.

You rang?

| Here is a recipe fragment to accomplish the description above.
| 
|     SENDER=`formail -rtzxTo:`

I would extract that within procmail rather than running formail, using
something like this old trick:

   :0
   * ! ^Reply-To: *\/[^ ].*
   * ! ^From: *\/[^ ].*
   * ! ^Sender: *\/[^ ].*
   * ! ^Return-Path: *\/[^ ].*
   * ! ^From +\/[^ ].*
   { SENDER }  # unset it and don't bother responding
   :0E
   { SENDER="$MATCH"

    [rest of reply routine]

   }

And inside that reply routine I'd change this:

|     # Only process the mail if it hasn't exceeded the maximum
|     :0
|     * ? test $COUNT -le $MAXIMUM
|     | $PROCESS

to this:

     :0 # passes if $COUNT <= $MAXIMUM
     * $ $MAXIMUM^0
     * $ -$COUNT^0
     * .1^0
     | $PROCESS

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