computer guy
MIT Department of Mathematics Computer Help

Home
New User Help
Systems Available
Printing
Programs Available
Dial-up Access
Policies
FAQ
Problems
Valid XHTML 1.0!

SpamAssassin

All e-mail sent to the Math Department is filtered by a program called SpamAssassin.

The way the SpamAssassin works is that each incoming e-mail is examined by the filter which identifies individual characteristics common to spam (unsolicited marketing e-mail) and assigns each of them a point based rating based on how "spammy" that characteristic is. Once a certain amount of points is reached, action is taken by the filter.

Our current set-up is that once a message is considered spam by the filter the subject line is then relabeled "*****SPAM*****"

If you sign-up for any product updates and/or newsletters from commercial companies, and you wish to receive these unmarked as spam, you have the following two options.

Opting out of SpamAssassin

If you wish to stop having SpamAssassin relabel your e-mail do the following:

  1. Using your favorite editor (emacs, vi, pico, etc.) open up .spamassassin/user_prefs in your home directory
  2. Find the line that says:

         # required_score     5
     
  3. Change it to:

         required_score     100
     
  4. Make sure to remove the # at the beginning of the line and then save the changes to the file.

Creating a personal "whitelist"

To ensure that SpamAssassin does not label e-mails from specific people that you consider legitimate e-mail as spam do the following:

  1. Using your favorite editor (emacs, vi, pico, etc.) open up .spamassassin/user_prefs in your home directory
  2. Find the lines that say:

    # Whitelist and blacklist addresses are now file-glob-style patterns, so
    # "friend@somewhere.com", "*@isp.com", or "*.domain.net" will all work.
    # whitelist_from someone@somewhere.com

     
  3. Under these lines add a line such as the following for each person you wish to receive e-mail from unlabeled by SpamAssassin:
     
    • whitelist_from myfriend@aplace.math.edu
    • change myfriend@aplace.math.edu to a real e-mail address
       
  4. Save the changes to the file

Creating a personal "blacklist"

If you find yourself constantly receiving spam from a specific e-mail address that is getting through the spam filter you can put them on your "blacklist". A blacklist is a list of e-mail addresses which send spam which are normally not caught by SpamAssassin. If an e-mail is received from an e-mail address in the blacklist it will be marked as spam.

To create a blacklist do the following:

  1. Using your favorite editor (emacs, vi, pico, etc.) open up .spamassassin/user_prefs in your home directory
  2. Find the lines that say:

    # Whitelist and blacklist addresses are now file-glob-style patterns, so
    #"friend@somewhere.com", "*@isp.com", or "*.domain.net" will all work.
    # whitelist_from someone@somewhere.com

     
  3. Under these lines and after any whitelist entries you may have add a line such as the following for each person you receive e-mail from that you would like marked as spam by SpamAssassin:

    blacklist_from spammer@spamcity.com (change spammer@spamcity.com to a real e-mail address)
     
  4. Save the changes to the file

Directing Tagged Messages To Another Mailbox

Below are instructions on how to have e-mails marked as spam by the spam filter automatically be sent to a separate mailbox for you to view at your leisure.

For Pine Users:

Start from pine's main menu.

  1. Press S for Setup.
  2. Press R for Rules; then press F for Filters.
  3. Press A for Add.
  4. Initially, the Nickname field should be highlighted. Select it by pressing enter/return, then set the nickname to "Spam Filter".
  5. Under the section FILTERED MESSAGE CONDITIONS BEGIN HERE highlight (using the arrow keys) Add Extra Headers then press X and enter "X-Spam-Flag". After you do this, the line allowing you to set the match pattern for X-Spam-Flag should be highlighted. Press enter/return, then as the text to be added enter YES (all caps)
  6. Check the CURRENT FOLDER CONDITIONS BEGIN HERE section. Make sure that the Specific option is set and the Folder List is "INBOX". If not, make the required changes so that that is the configuration.
  7. Scroll down to the ACTIONS BEGIN HERE section. Make sure the Filter Action option is set to Move. Select the Folder List item in that section, and set it to "spam".
  8. Press E for Exit Setup and press Y to commit the change. You may be asked to create the spam folder; accept that change if this happens.
  9. Press E again for Exit Setup and press Y to commit the change.

At this point your filtering setup is in place; whenever you read mail, suspected spam will wind up in the "spam" folder in the "mail" directory within your home directory

For mail, elm and mutt users:

  1. Using your favorite editor (emacs, vi, pico, etc.) create the file .procmailrc in your home directory
  2. Insert the following:

    MAILDIR=$HOME/Mail
    :0:
    * ^X-Spam-Flag: YES
    spam

     
  3. Save the changes to your file.
  4. Mail marked as spam can be read with the -f Mail/spam flag to your mail program

(Note to users already using procmail: all you have to do is add the three-line rule above to your .procmailrc. You can position it where you like to allow other rules to apply to suspected spam first.)

Some of these instructions and material are taken or derived from the following:

http://www.cites.uiuc.edu/email/spamassassin.html
and http://www.its.caltech.edu/its/services/internetapps/email/spam.shtml

Training SpamAssassin

Recent versions of SpamAssassin include a Bayesian learning filter with which you can train SpamAssassin with your collection of non-spam and spam. This will make it more accurate for your incoming mail. You can do this using the sa-learn command. In order to use this you will first need to redirect tagged spam to another folder as described above and then do the following:

For Pine Users:

Start from pine's main menu.

  1. Press L for Folder List
  2. Press A to Add a New Folder
  3. Name the folder "spam-train"
  4. Open your INBOX in Pine. For each spam that wasn't tagged as such by SpamAssassin, save it to your spam-train folder. Ensure that your INBOX is free of spam then exit Pine.
  5. Run the following commands:
    sa-learn --mbox --spam ~/mail/spam-train
    sa-learn --mbox --nonspam /var/mail/$username (replace $username with your username)

Depending oh how much spam you get that isn't marked as such by SpamAssassin you should do steps 4 and 5 daily or weekly. Note that SpamAssassin will remember what mails it's learnt from, so you can re-run this as often as you like.

For Users of Other Mail Programs: The concepts are similar to what is done in Pine, you make a mail folder for spam not caught by SpamAssassin. Move all those messages from your inbox to that folder and then run "sa-learn --mbox --spam" on your spam training folder and "sa-learn --mbox -nonspam" on your inbox

Still having trouble?

If you receive a large number of e-mails from different e-mail addresses that are similar in nature and contain similar phrases we may be able to customize SpamAssassin to block these, please forward them to me.