Difference between revisions of "Filtering Spam with Procmail"

(No difference)

Revision as of 21:35, 28 January 2015

The CS Department uses SpamAssassin on the Grad/Research Net only to track spam email and to tag the Subject line of that spam with with the text ** SPAM **.

We do not filter out or delete any e-mail tagged as ** SPAM **. We merely tag it as such, and you can use your own mail client or procmail to filter/delete/move that mail.

(The exception is mail with viruses. Our mail server's virus checker will remove mail that contains any virus that it can detect.)

Customizing your SpamAssassin preferences

Please see Spamassassin Spam-Tagging.

Configuring your account to filter spam-tagged mail with procmail

Procmail is a system that allows you to manipulate mail messages as they arrive. There is a global (server) procmail configuration, but you can also create your own configuration for your account. There are many options for procmail, but you can find useful tips and recipes for procmail at: http://lipas.uwasa.fi/~ts/info/proctips.html

As an easy example, let's take a user named joe. joe wants to file spam into a separate spam folder for later review.

Create a file called .procmailrc (don't forget the dot) in your home directory.

Edit the file to look something like this:

MAILDIR=/users/joe/Mail
DEFAULT=/var/mail/joe
LOGFILE=$MAILDIR/procmaillog
LOCKEXT=.lock

:0:
* ^X-Spam-Flag: YES
SPAMFOLDER

The first line, MAILDIR, sets the mail directory to be the Unix directory on our Grad/Research Net systems that you use to store your mail folders.

The DEFAULT line is standard; it is the location of your inbox.

The LOGFILE can be set to keep a log of procmail activities for your account.

Note: Please clean out the your procmaillog file occasionally with the following command on a Grad/Research Net : cat /dev/null >/users/joe/Mail/procmaillog (Of course, change "joe" to your account name.)

The LOCKEXT line is needed as is.

Now, the section beginning with :0: files mail flagged as spam to a folder called SPAMFOLDER. That folder will be stored in the directory defined by the first line in the file, MAILDIR.

The * ^X-Spam-Flag: YES line matches any message with an X-Spam-Flag: header whose value is YES.

Save your .procmailrc file.

At a unix command prompt, run the following command:

chmod 600 .procmailrc

Procmail, which is run as part of the normal email delivery process, will now filter out all spam-flagged email.

Now, the most important step here is to wait a bit and see if **SPAM**-tagged mail continues to show up in your inbox. If you haven't seen any of it in bit, then go to your new spam folder. (It may depend on your mail program how you find that mail folder to view.) Do you see the SPAM-tagged messages there? If so, it's working. If not, contact CS IT Support, and we'll try to figure out why it isn't working for you.

VERY IMPORTANT: When should you check your spam folder? Often. Why? Two reasons. 1) There could be some false positives in your folder, mail tagged as SPAM because it looked like spam, but may actually not be spam. Example? You might be subscribed to a mailing list, and the list sends you mail that looks like spam. 2) You need to go through *regularly* and clear out (delete/remove) your spam folder of spam messages to conserve room on our home directory server disks. Some of the **SPAM**-tagged mail could be very big, especially if it contains attachments. This could fill up our disks rapidly. Please make sure you monitor your spam folder and keep it clean regularly.