Procmail hints

Procmail is a very useful tool for processing and filtering your mail. On OCCS, new accounts are created with a few simple procmail rules included. However, you might want to add more in and/or change things around.

Basic elements

Procmail is run automatically as part of the normal mail delivery process. You can control the behavior of procmail by creating/modifying a special file called .procmailrc.

Here is what a sample file looks like:

MAILDIR=$HOME/Mail	# make sure this exists!

# Anything with a score over 10 goes away.  15 would be safer, but in several
# months of testing I have had zero false hits that scored between 10 and 15.
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*

# Forward everything else to your Oberlin account


SHELL is used when running programs from within procmail. MAILDIR is used as the prefix for where emails could be filed away (if delivered locally).

You can enable logging by adding in a line just after the MAILDIR one:


This is useful when you are trying to debug things or just to have a record of mail received. Beware that this file will continue growing!

Mail forwarding

The last rule says to forward everything else to a different account. You can change the email address and have things sent somewhere else (e.g., GMail) or even to multiple accounts if you so choose.

Delete all three lines to end forwarding. You now will need to check your email on OCCS.

Spamassassin and Procmail

The rule given above deletes everything with a spamassassin score of 10 or more. However, spamassassin might have marked things as being spam with a lower score than that. You can add in the following rule after the first to file away probable spam messages to be gone through manually.

# Probable spam goes into Junk
* ^X-Spam-Flag: YES

Note that we don't have to specify where the mailbox is because of the value of MAILDIR.

Preventing mail deletion

One thing I worry about is having mail from students be labeled as spam and deleted. To prevent this, I tell students to include the course number in the subject line.

### make sure I get class mail
* ^Subject:.*(cs|csci).*[0-9][0-9][0-9]

If this recipe is the first one in my .procmailrc file, then I can guarantee none of their email gets lost. Well, only if they can follow directions!

Last Modified: June 07, 2007 - Benjamin A. KupermanVI Powered