Several people have asked me about spam filtering lately. We run a program called SpamAssassin on the mail server. SpamAssassin uses a variety of local and network tests to identify spam and adds headers to incoming messages indicating the results. These headers can be used to filter the messages identified as spam. As of this writing (July 2005), SpamAssassin is not enabled on user accounts by default.

To enable it for your incoming email, you need to setup a program called procmail that runs on the mail server and can do a variety of things with your messages as they arrive (such as filing them into mailboxes automagically). We will use it to run SpamAssassin and (optionally) act on the results.

First, setup your ~/.procmailrc to pass incoming messages through SpamAssassin:

# This recipe passes each message through spamassassin
:0fw: .spamassassin.lock
# This recipe puts messages flagged as spam into the Junk mailbox
* ^X-Spam-Status: Yes

If you prefer to let your email client filter out the spam using the headers added by SpamAssassin, comment out or delete the second recipe.

Second, if you don't already use procmail, you need to enable it with a one-line ~/.forward file (admittedly a fairly long line):

"|IFS=' ' && test -f /usr/bin/procmail && exec /usr/bin/procmail -Yf- || exit 75#YOUR-USER-NAME-HERE"
The YOUR-USER-NAME-HERE should be replaced with your login name. Having this in the command makes it easier to debug problems on the server.

You are done. Use your mail client to inspect the headers of incoming messages and you will see the results of SpamAssassin's work. If you let procmail file the Junk for you, you'll have to look in that mailbox (~/mail/Junk in the above example) for messages that tested positive.

-- GeorgeFerguson - 28 Jul 2005

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2005-08-01 - GeorgeFerguson
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback