Procmail is a mail filtering program that operates on the mail server. It allows users to sort and filter their email using whatever methods they deem best.

Splitting mail into separate mailboxes

The primary use of procmail is to filter messages into several mailboxes, based on the headers. This filtering is done based on the rules set down in your ~/.procmailrc file. As an example, the following recipe would put all messages sent to g_beckman to a g_beckman box:

* ^TO_g_beckman

This is especially handy when you are subscribed to several mailing lists, or forward mail from several accounts to a single machine.

Overall, Procmail is a very powerful program, but it isn't trivial to learn. I recommend this tutorial, based on a talk given by Joe Gross several years ago. It's still useful, and a good starting point.

Filtering Spam

Spam filtering generally takes place using SpamAssassin. This program analyzes your mail for its likely level of "spamminess", and gives it a numeric score; anything greater than 5 is generally considered spam, and is marked up as such, by adding an "X-Spam-Status: yes" header.

The new mail server automatically runs all emails through spamassassin. You can filter messages that SpamAssassin marks as spam by adding the following recipe to your .procmailrc file:

* ^X-Spam-Status: yes

Other notes:

  • You can modify Spamassassin's defaults by editing ~/.spamassassin/user_prefs; you can get more information from the man page for Mail::SpamAssassin::Conf.
  • SpamAssassin can also do Bayesian filtering. Summary: Bayesian filtering is where you give your program a history of your messages, divided by the user into "spam" and "ham". This information is used to look at later messages and determine whether or not they are "spam" or "ham". It's quite useful, but requires a fair bit of initial setup by each user to be used correctly. For more information, run man sa-learn, and set 'use_bayes 1' in your ~/.spamassassin/user_prefs file.