procmail
[Top] [All Lists]

Re: procmail and commas

1998-07-28 23:30:46
I want a message to be filtered a certain way depending on how many commas
are in the To: field or CC: any suggestions????

Well, I'm not sure what you want to do with the info, so I'll set LOTS of 
variables for you...

   TOTALRECIPIENTS="0"

   :0
   * ^To: \/.*
   * 1^1 MATCH ?? ,
   {
      TOSCORE="$="
      TORECIPIENTS=`expr $TOSCORE + 1`
      TOTALRECIPIENTS="$TORECIPIENTS"
   }

   :0
   * ^Cc: \/.*
   * 1^1 MATCH ?? ,
   {
      CCSCORE="$="
      CCRECIPIENTS=`expr $CCSCORE + 1`
      TOTALRECIPIENTS=`expr $TOTALRECIPIENTS + $CCRECIPIENTS`
   }

So, TOSCORE and CCSCORE tell the number of commas in each respective header, 
TORECIPIENTS and CCRECIPIENTS tell the number of recipients in each header
(assuming that it's equal to number of commas + 1), and TOTALRECIPIENTS
tells the sum of the recipients in both headers.

You can do tests based on the recipient number like

   :0
   * TOSCORE ?? [456789]
   toomanytos
 
Chris

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