Spam Filtering: 10 Minute Quick Install Guide

This page gives an easy, step-by-step guide to set up spam filtering via the SpamAssassin program for users of the UIUC Mathematics Department's Unix Systems (MUSes) network. The set-up provided here is a slightly customized version of the default SpamAssassin configuration. It should be appropriate for nearly all users, with no further customization needed. (If you are interested in such customization, consult the Spam Filtering Page.)

  1. Check if you have a directory "mail" (with lower case "m") off your home directory (using "ls" in your home directory); if not, create one (using "mkdir mail"). This is the directory in which the "spam folder" will be placed. (If you are using pine, you probably have already a "mail" directory, since pine uses that directory as the default location for all its folders.)

  2. Check if you have a file named ".procmailrc" in your home directory (note the period at the beginning of the file name) (using "ls -a" in your home directory). If you don't, go to the next step. If you do have such a file, move it to a backup location (e.g., using "mv .procmailrc .procmailrc.bak"). In the next step a fresh .procmailrc file containing an appropriate spam filtering recipe will be created, and moving any existing .procmailrc file to a backup location prevents overwriting of the old .procmailrc file. Chances are that you don't have such a file, but if you do, the file was probably intended to filter out spam and is no longer needed as the .procmailrc file provided here serves the same purpose and does a much better job at that.

  3. Copy the sample procmailrc file to .procmailrc in your home directory. The following command, issued from your home directory, accomplishes this:
    cp /home/users/hildebr/pub/procmail.sample2 .procmailrc
    
    With this step, spam filtering with SpamAssassin is in place. All messages identified as spam by SpamAssassin will be redirected to a folder (file) "spam" inside the "mail" directory. The remaining steps are recommend, but not necessary.

  4. Test the spam filtering by sending yourself two emails, one containing an ordinary (non spam) message, and another containing a spam-laden message intended to trigger the spam filtering mechanism. (An example of the latter is this sample spam message which came with the spamassassin program.) This can be accomplished by the following two commands, where "user" is your login name (or email address without the @math.uiuc.edu part).
    mailx -s "non-spam" user  < /home/users/hildebr/pub/nonspam.txt 
    
    mailx -s "spam" user < /home/users/hildebr/pub/spam.txt 
    
    (Note that each of these commands must be on a single line; depending on your browser settings, you may see the commands wrapped onto two lines.) If you now access your email as usual, the first (non spam) message should appear in your message index as usual, but the second (spam) message should not show up. Instead, there should be file "spam" inside the "mail" directory (this file is the "spam folder") containing this message. If the non-spam message does not show up, something went wrong, and you should delete the .procmailrc file to avoid losing any email. Deleting the .procmailrc file (or moving this file to a different location) effectively turns off spam filtering.

  5. Create an alias for quick access to the spam folder. To provide a convenient access to the spam folder, create an alias "checkspam" by adding the following line at the end of the .cshrc file, located in your home directory. (Note the period at the beginning of ".cshrc".) This assumes that pine is your usual email reader; otherwise replace "pine" by the name of your favorite mail reader, e.g., "mail", "mailx", "elm", "mutt", "dtmail". (Dtmail is the default graphics based mail program in the CDE environment. If you use a mail program other than those mentioned, a different syntax may be needed.)
    alias checkspam 'pine  -f $HOME/mail/spam'
    
    (Note the two forward ticks enclosing the argument of "checkspam".) To activate and test this alias, log out and log back in or read in the .cshrc file explicitly with the following command:
    source $HOME/.cshrc
    
    If you get an error message, the alias command may have been improperly entered. Open the .cshrc file with an editor and fix any problems you notice (in particular, make sure the quotes are present and in the right place), or remove the "alias checkspam" line. If there are no error messages at this stage, the alias should work, and the simple command checkspam should fire up the mail program you specified and display an index of all messages that have accumulated in the spam folder.

    The "checkspam" program is mainly intended to check for any "false positives" that may have improperly been identified as spam. You need not do anything with the spam messages. In fact, you can simply let the spam folder accumulate, and delete the entire folder (the file "spam" inside the "mail" directory) when it gets too large (after having dealt with any false positives).

  6. Add a whitelist. If you did send yourself a spam test message as shown above, the program should have created a directory named .spamassassin (note the period!) off your home directory, and a file user_prefs inside this directory. The latter file contains a line beginning with
    # whitelist_from ...
    Edit this line by removing the hash mark (#) and entering any addresses you want to "whitelist", separated by spaces. I recommend the following:
    whitelist_from *.edu *.ac.uk *.org
    
    This will whitelist any academic addresses in the US and UK, as well as "org" addresses, such as ams.org, or maa.org. You can always add addresses at a later point. To test the whitelist, send yourself again a sample spam message as in Step 4. This time, the message should appear within the regular mail, since the sender address (i.e., your address) is in the whitelist as it is of the form *.edu.

    Additional resources

    For more information about the local spam filtering installation, and for tips on how to further customize your spam filter, consult the Spam Filtering Page.


    Last update: Thu 08 Jan 2004 08:31:09 AM CST A.J. Hildebrand