Computing & Communications Center
Helpdesk

Mail Filtering for UNIX

This guide will demonstrate how to configure filters on the WPI UNIX systems using either Sieve, Procmail, or pine. The PINE filter moves messages that have at least 70% probability of being spam into an alternate folder. Filters set up with Sieve or procmail will:

sieve

This example shows mail filtering with Sieve, which is the mail processing language that the cyrus mail server implements. First, you have to make a file which lists the commands, such as:

require ["fileinto", "reject"];
if header :contains "X-Perlmx-Spam" "Gauge=XXXXXXXXX" { discard; stop; }
if header :contains "X-Perlmx-Spam" "Gauge=XXXXXX" { fileinto "Spam"; stop; }

The fileinto action puts the mail into a folder named Spam. The folder would need to be created by the user using an imap-capable mail reader. Anything not matched by the sieve filter would then be delivered to the inbox.

After the file of commands is created, you need to compile it into a file which the mail server can process. You can do this on any of of the ccc Linux systems. The command should be:

sieve command-file-name

The above command compiles the textual command file, such as the example shown above, into a file in your home directory named .sieve. The .sieve file will be owned by cyrus, which is the mail processor's user name. That way it will be readable by the mail processor.

The sieve command also checks your home directory permission to be sure that the .sieve file is accessible. The changes it might make should not be harmful to your directory.

You can remove the sieve processing by removing the .sieve file. You can replace the .sieve file with another compilation of a sieve command file any time you want, too.

Procmail

Our systems also have Procmail installed for mail filtering purposes. This example shows mail filtering with Procmail. The commands will need to be put into a file named .procmailrc in the user's home directory.

:0
* ^X-Perlmx-Spam: Gauge=XXXXXXXXX
/dev/null

:0
* ^X-Perlmx-Spam: Gauge=XXXXXX
$HOME/mail/Spam

:0
! username@imap.wpi.edu

Note: username is your username.

In order to use Procmail, a user must have a .forward file in their home directory with 0600 permissions, so that the system thinks that the file is "safe". The following line must be added to the .forward file:

|/usr/bin/procmail

pine

If you read your mail solely using the UNIX mailreader called Pine, then there is an alternate method for filtering, as detailed on the Filter Spam with Pine page.

Maintained by itweb.
Last modified: Jun 28, 2007, 15:29 UTC
[WPI] [Home] [Back]