On Wed, 29 Jul 1998 01:14:26 -0500 (CDT), Christopher Lindsey
<lindsey(_at_)ncsa(_dot_)uiuc(_dot_)edu> wrote:
:0
* ^To: \/.*
* 1^1 MATCH ?? ,
{
TOSCORE="$="
TORECIPIENTS=`expr $TOSCORE + 1`
TOTALRECIPIENTS="$TORECIPIENTS"
}
This will grab the number of commas in the +first+ To: line. (Walter
Dnes posted a similar recipe.)
It is perfectly permissible to create a message with the following
recipient headers:
To: you
To: friend, buddy
To: someone
Cc: secretary
Cc: "boss's wife"
A correct recipe should add all of these, if I understand the intent
correctly.
Here's a somewhat pathetic attempt at this:
:0
RECIPIENTS=| formail -czxTo: -xCc: | tr -dc ',\012' | wc -c
The standard caveat about how "Elvis, King of Kings"
<parsley(_at_)graceland(_dot_)com>
really should count only as one applies, of course.
Eli the Bearded's Email Addressing FAQ has an appendix with a more or
less real RFC822 address parser. You probably don't want to employ
that from within Procmail, but should give you an idea of what you're
up against. <http://www.netusa.net/~eli/faqs/addressing.html>
You can do tests based on the recipient number like
:0
* TOSCORE ?? [456789]
toomanytos
You mean ^^[456789]|[1-9][0-9]
In general, I'd prefer to set up scores directly so they trigger when
a threshold is exceeded; prototypically, something like
:0
* -10^0 # Permit up to ten points (ten commas in this case)
* 1^1 (somehow add one for each comma)
toomanytos
(This is pseudo-code; the comment after the first score line shouldn't
be there. And of course, my own solution isn't very helpful with
scoring. If you like the idea, you can do something like
:0
* -10^0
* $ $RECIPIENTS^0
toomanytos
but here, it doesn't really matter whether you use scoring or regex
comparisons. Except number comparisons in regexes are hard to do right
when you're going over 99 or so.)
/* era */
--
Paparazzi of the Net: No matter what you do to protect your privacy,
they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>