I want to filter junk messages sent out to long lists of recipients. Is
there a way to tell procmail to reject/bounce any e-mail that has a "To:" or
"Cc:" header which contains (say) more than a hundred occurrences of the "@"
symbol (and hence e-mail addresses)?
There is a simple recipe in the "Spam Bouncer" procmail script
(by Catherine A. Hampton, see http://www.hrweb.org/spambouncer/):
# Ridiculously overlong To: or Cc: headers
:0
*
^(To|Cc):(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*,$?\
(_dot_)*(_at_)(_dot_)*,$?(_dot_)*(_at_)(_dot_)*
{
:0 f
| ${FORMAIL} -A"X-SBRule: Overlong To: or Cc:"
:0
{ BLOCKTAG=yes }
:0
* BLOCKREPLY ?? NOTIFY
{ BLOCKTHIS=yes }
}
You will want to change the action block to whatever you want.
I have been using Spam Bouncer for a couple of weeks now and
it is excellent! So why not just download and install the whole thing :-)
Martin
Martin(_dot_)Ward(_at_)durham(_dot_)ac(_dot_)uk http://www.dur.ac.uk/~dcs0mpw/
Erdos number: 4
Maintainer of the G.K.Chesterton web site: http://www.dur.ac.uk/~dcs0mpw/gkc/
Shortcuts: http://i.am/mw and http://i.am/gkc -- try them!
Vote against spam: http://www.politik-digital.de/spam/en/