For most users, a tool called SpamAssassin is now being used to check your incoming mail for spam ("spam" is generally defined as unsolicited commercial email). This operation does not delete or even redirect email. It simply adds a "score" to the mail headers, which you can use to help sort your mail.
Most mail programs allow you to sort (or filter) incoming mail based on a number of criteria. You can use this ability combined with the information provided by SpamAssassin to help you file likely spam. One common technique is to have suspected spam placed in a mailbox named "spam" which you check less frequently than your inbox. You should not have suspected spam deleted automatically because SpamAssassin does make mistakes, and you will lose mail of you do this.
When SpamAssassin scans a message, it checks for certain patterns and phrases in the message. Each of these patterns or rules has a value. Values can be either positive or negative, with positive values indicating likely spam, and negative scores indicately likely legitemate mail. The sum of the values for the patterns that appear in the message is called the score. If the score exceeds a settable threshold, the message is flagged as probably spam.
There are two mail headers that are added to reflect the result of the scan. You can use these headers to filter the mail. Here are those headers for a message that SpamAssassin thinks is spam:
X-Spam-Status: Yes, hits=6.2 required=5.0
tests=GAPPY_TEXT,EXCUSE_10,DOUBLE_CAPSWORD,CLICK_BELOW,
LINES_OF_YELLING,LINES_OF_YELLING_3,LINES_OF_YELLING_2,
UNSUB_PAGE,SUPERLONG_LINE,WEB_BUGS,CLICK_HERE_LINK,AWL
version=2.31
X-Spam-Level: ******
and here is one that SpamAssassin thinks is NOT spam:
X-Spam-Status: No, hits=1.5 required=5.0
tests=VERY_SUSP_RECIPS,SIGNATURE_DELIM
version=2.31
X-Spam-Level: *
In each case, the X-Spam-Status: header gives a summary
of the scan results, including the score, threshold, and a list
of matching rules. The X-Spam-Level: header has a number
of asterisks equal to the message score.
The details of how you filter your mail depends on the program you use to read your mail.
Here is an example .procmailrc file that will put all mail that SpamAssassin thinks is spam in the file spam in your mail directory.
MAILDIR=$HOME/mail LOGFILE=$HOME/mail/log :0: * ^X-Spam-Status: Yes spam
This does the same thing, except it files all messages with a score greater than or equal to 8 (note the 8 asterisks). The backslashes are necessary, because otherwise procmail will treat the asterisks as special characters.
MAILDIR=$HOME/mail LOGFILE=$HOME/mail/log :0: * ^X-Spam-Level: \*\*\*\*\*\*\*\* spam