James Allen wrote:
I want a message to be filtered a certain way
depending on how many commas are in the To: field
or CC: any suggestions????
Let's start with sample lines like so embedded in headers
To: a,b,c,d,e,f,g,h
Cc: x,y,z
If you want to count commas, you need to use scoring.
Defensive programming demands that you you check for allegedly
"impossible situations", so I've thrown in code to count To:
and Cc: headers. How you handle occurences of more than 1 is
up to you. This code merely provides a count. The code
snippets below match a header, count the commas, and store the
count to a variable. The rest is up to you.
:0
* 1^1 ^To:
{ LINES_TO = $= }
:0
* 1^1 ^Cc:
{ LINES_CC = $= }
:0
* ^To:\/.*$
* 1^1 $MATCH ?? ,
{ COMMAS_TO = $= }
:0
* ^Cc:\/.*$
* 1^1 $MATCH ?? ,
{ COMMAS_CC = $= }
Setting VERBOSE=ON yields the following snippet in the logfile
procmail: Score: 1 1 "^To:"
procmail: Assigning "LINES_TO=1"
procmail: Score: 1 1 "^Cc:"
procmail: Assigning "LINES_CC=1"
procmail: Assigning "MATCH="
procmail: Matched " a,b,c,d,e,f,g,h"
procmail: Match on "^To:\/.*$"
procmail: Score: 7 7 ","
procmail: Assigning "COMMAS_TO=7"
procmail: Assigning "MATCH="
procmail: Matched " x,y,z"
procmail: Match on "^Cc:\/.*$"
procmail: Score: 2 2 ","
procmail: Assigning "COMMAS_CC=2"
--
Walter Dnes <waltdnes(_at_)interlog(_dot_)com> procmail spamfilter
http://www.interlog.com/~waltdnes/spamdunk/spamdunk.htm
Why a fiscal conservative opposes Toronto 2008 OWE-lympics
http://www.interlog.com/~waltdnes/owe-lympics/owe-lympics.htm