Rick Troxel asked about * ! ^(To|Cc):
| Won't this match any header that is neither To: nor Cc: ?
No, it will match on an entire head where neither ^To: nor ^Cc: is present.
If you wanted to match on the presence of a header that is neither To: nor Cc:
you could do this,
* ^([^TC]|.[^oc]|Tc|Co)
[Translation: if the first character is neither T nor C, regardless of the
rest, ok; if the second character is neither o nor c, regardless of the first
character and the rest from the third character on, ok; if the first two
characters are Tc or Co, ok. Note that the second alternative (the second
character is not an o nor a c) lets through T: and C:.]
That would count the Unix From_ line, however. I like this approach better
(the empty line at the neck and the Unix From_ line shouldn't count either):
# H is implicit; it's here as a reminder to readers because usually
# line-counting scores are computed on the body
:0H
* 1^1 ^.*$
* -1^1 ^$|^From ()
* -1^1 ^(To|Cc):
routine_for_presence_of_other_headers
Since there should always be From:, Date:, and Message-Id: fields, that
will match on all legitimate mail (and on most illegitimate mail).