This article addresses using SpamAssassin to filter suspected spam into a separate folder. It is not generally recommended that you directly delete mail identified as spam by SpamAssassin due to the possibility of false positives.
This article presumes that you have procmail working as your method of mail filtering. See Using the procmail program.
First install SpamAssassin. This can be done by using CPAN (as root):
$ perl -MCPAN -e shell cpan> install Mail::SpamAssassin
Create a mail folder named "spam" (or change the variable below, then add the following to your ~/.procmailrc file
NOTE: in the current version of spamassassin, the -P option has been removed (this is default behaviour now). However currently (Jun 2003) spamassassin will simply print a message to stderr to this effect and continue, so its inclusion is harmless.
SPAMFOLDER=spam # # SpamAssassin check :0 wf | /usr/bin/spamassassin -P # # File as SPAM :0 w :$SPAMFOLDER/.lock * ^X-spam-status: Yes $SPAMFOLDER/.
The procmail recipes above should be placed after your recipes that filter mail from mailing lists and other "known" sources. Probably the most effective placement will be right before the usual "catch-all" recipe that places unrecognized messages in your inbox. This placement avoids running SpamAssassin on every single piece of mail while still giving excellent protection.
Notice that the second recipe, which files the spam into the spam folder uses procmail's built-in method of delivering into MH/nmh folders. There's no need to maintain an unseen sequence for spam, after all.
As you first begin to run this check your spam folder regularly. It may take some tuning to eliminate the false positives.
The following trick is quite useful:
:0 w :evilspam/.lock * ^X-spam-status: Yes, hits=[0-9][0-9] evilspam/.
.. this is an ADDITIONAL rule which runs first to filter out spam candidates with double figure spam hits into a separate spam folder which is much less likely to contain false positives. If you're brave, you could even send these high-scoring spam emails straight to /dev/null instead after trying it out for a while.
To help with false positives, you can add two options to ~/.spamassassin/user_prefs
rewrite_subject 1 subject_tag *_HITS_*
Now all of the messages in the spam folder will have their weighting prepended to the subject. Sorting the folder on subject puts the messages with lower scores (most likely false-positive candidates) at the top.
..... this article needs someone to describe adding buttons to rescue false positives ...
you can use:
macro index X "| spamassassin -r" "Spamassassin submits Mail to Razor"
macro pager X "| spamassassin -r" "Spamassassin submits Mail to Razor"
only if you have installed Razor (in debian: apt-get install razor)
macro index S "| spamassassin -d | sa-learn --spam --single --no-rebuild" "Spamassassin -- learn as Spam"
macro pager S "| spamassassin -d | sa-learn --spam --single --no-rebuild" "Spamassassin -- learn as Spam"
macro index H "| spamassassin -d | sa-learn --ham --single --no-rebuild" "Spamassassin -- learn as noSpam"
macro pager H "| spamassassin -d | sa-learn --ham --single --no-rebuild" "Spamassassin -- learn as noSpam"
this will not work with spamassassin versions earlier 2.50.
This article was assembled from my own procmail recipes and from info gleaned from the exmh-users email archive, with subsequent contributions from random exmh users :). Specific articles used are: