This document is designed to assist ECE affiliates using UNIX and Linux with procmail in setting up mail filters to decrease the amount of "junk mail" (also known as "spam") viewed in their Inbox. Using these "Advanced" instructions, you may specify the spam score that is used to filter, and create rules to prevent specific e-mail messages from being tagged as "spam."
We assume that you already know how to use procmail and its recipes, and have set up a basic .procmailrc file. At this time our department is unable to offer full support for procmail users, but we will attempt to answer any questions that you have.
The easiest way to filter spam into a separate folder is to use the X-Spam-Flag header. A very basic filter, which directs all mail with the X-Spam-Flag of "YES" into a folder called Spam, looks like this:
# Catch SPAM
:0:
* ^X-Spam-Flag: Spam YES
Spam
This is a good first pass at getting mail that is likely to be spam set aside so you can look at it later. On the minus side, it forces you to use the UCSD spam filter's default setting, and it doesn't have a way to filter mail that you know isn't spam out of the Spam folder.
For example, you might get mail from the organic-houseplants mailing list and find that it always ends up on your Spam folder. Or, you might receive a lot of e-mail newsletters and offers that you want, even though they're tagged as spam, and feel that you'd like to set your tolerance level a little higher. Following are some ways to enhance this rule in order to do that. You may use either or both methods below.
UCSD's spam filtering system uses an algorithm to determine the likelihood that a given piece of mail is "spam," based on a variety of criteria. It assigns each message a score, representing the probability that the message in question is spam. UCSD's system will tag a message as "spam" if it receives a score of 5.0 or above. You may wish to select a score other than five for your filtering needs.
The score is represented in the mail message graphically in the X-Spam-Level header -- the number of asterisks (*) in the line denote the "spam score." Choosing a lower value will result in a greater volume of spam being directed to your Spam folder, but it will also increase the likelihood of a legitimate mail message accidentally being sorted as spam.
To determine the level at which you feel comfortable filtering, we recommend that you examine the assigned score on a variety of messages in your inbox. To view this, you may need to tell your mail reader to "show headers."
To enhance the recipe above to change the tolerance level, you must create a recipe with the appropriate number of asterisks. Each asterisk must be prefaced with a backslash, so a setting of "6 or higher" would look like:
* ^X-Spam-Level: Level \*\*\*\*\*\*
The whole recipe would now look like this:
# Catch SPAM
:0:
* ^X-Spam-Flag: Spam YES
* ^X-Spam-Level: Level \*\*\*\*\*\*
Spam
To prevent a particular message from being tagged as spam, it must be caught before the spam filter can redirect it into the Spam folder. An easy way to do this is to add additional stipulations to your spam recipe, requiring that a message not be from particular addresses or bearing particular Subject lines before it can be added to Spam. The simplest way to do this is with an exclusion recipe, using the exclamation point (!) to mean not.
For example, a pattern to exclude mail to the sysadmin-l mailing list, which tags its Subject lines with [sysadmin-l], could look like:
* !^Subject: .*[sysadmin-l]
You can filter on any portion of any header — so, in the From line, this could be an e-mail address or any visible name or word in the line. In general, put .* in front of the pattern you wish to match. You do not need a * to indicate the end of a pattern -- this is built in to procmail.
A pattern to exclude mail from the Green River Optical Society mailing list could look like
* !^From: .*Green River Optical Society
while one to exclude mail from the Economics Life mailing list might be
* !^From: .*@econlife.com
You can stack any number of these exclusions on top of your X-Spam-Flag filter line, e.g.:
:0:
* !^Subject: .*[sysadmin-l]
* !^From: .*Free Will Astrology
* !^From: .*@econlife.com
* ^X-Spam-Flag: Spam YES
Spam
If you are also using the X-Spam-Level to specify a particular level, your entire recipe might look like:
:0:
* !^Subject: .*[sysadmin-l]
* !^From: .*Green River Optical Society
* !^From: .*@alanis.com
* ^X-Spam-Level: Level \*\*\*\*\*\*
* ^X-Spam-Flag: Spam YES
Spam
Questions
If you have any further questions or encounter problems while attempting to set up your spam filter, send an e-mail message to ecehelp@ece.ucsd.edu