Filter to Ban E-mail Addresses from File List

By David Efflandt


Banning e-mail addresses to fight spam or worms is not very effective because spammers use most any fake e-mail address (if they have an ounce, or is that milligram, of brains), and worms often pick random From addresses from the victim's Outlook address book. But somebody requested this, so here it is.

It can be run as an external procmail filter. It does not actually drop the mail, but adds an X-Drop header based on a match in any From or Sender header, that can easily be used in following recipe or other filter to drop it in the bit bucket. Note that any name or address in the list, so if you just put a domain in the list, it would flag any mail from that domain.

Typical .procmailrc:

MAILDIR=$HOME/Mail
LOGFILE=$MAILDIR/from
SHELL=/bin/sh
TRASH=/dev/null

:0 fw
| $HOME/banatest

:0
* ^X-Drop:.*yes
$TRASH

Script source Banatest

Another filter based on IP file list of abusive spam sources or relays may be more effective.