Spam filtering with procmail

procmail can be used to filter spam in multiple ways. It is possible to use the generated spam filter headers to filter spam, as described below. Or you can use SpamBayes to filter spam by training.

Filtering spam by X-Spam-Score

Below is an example for a ~/.procmailrc rule to filter all spam for level 4 or higher:

:0
* ^X-Spam-Score: .*[(][*][*][*][*]
$HOME/Mail/SPAM

# Spam-Score >= 4 is now "delivered" in SPAM
# Spam-Score < 4 is not yet "delivered" and goes to inbox

If (and only if) you are sure that all e-mail marked as spam with level 4 or higher can be thrown away immediately, change the above to:

:0
* ^X-Spam-Score: .*[(][*][*][*][*]
/dev/null

# Spam-Score >= 4 is now "delivered" to /dev/null.
# Spam-Score < 4 is not yet "delivered" and goes to inbox

A variant approach is to throw away most of the email but keep the sender line so that it is possible to see whether the spam filter has thrown away an important email by accident:

:0
* ^X-Spam-Score: .*[(][*][*][*][*]
| head -n 1 >>$HOME/Mail/SPAM-From-lines

# The senders for emails with Spam-Score >= 4 are now
# "delivered" into the email box SPAM-From-lines
# Spam-Score < 4 is not yet "delivered" and goes to inbox

Or you can choose to divide incoming e-mail into one of three classes; simply throw away, set aside to filter manually, and non-spam:

:0
* ^X-Spam-Score: .*[(][*][*][*][*][*][*][*][*][*][*]
/dev/null

# Spam-Score >= 10 is now "delivered" to /dev/null.

:0
* ^X-Spam-Score: .*[(][*][*][*][*]
$HOME/Mail/SPAM

# 4 <= Spam-Score < 10 is now "delivered" to SPAM
# Spam-Score < 4 is not yet "delivered" and goes to inbox

Contact us | Webmaster

Questions? Mail to helpdesk.win@tue.nl