Click here to get rid of any annoying frames

TOC


fetchmail, procmail, and spamassassin

Excerpted version. For the full and most current version. Go to http://linux.org.mt/article/killspam

The software I used are spamassassin, procmail, and fetchmail. My email client is Mozilla but you should be able to use KMail or other clients in the same way. The important thing is that they accept an "mbox" as the source of messages.

Here is the sequence of events which:

  1. Fetchmail connects to the mail server at regular intervals, fetches any new messages present and hands them over to procmail.
  2. Procmail pipes all incoming messages through spamassassin.
  3. Spamassassin uses its internal rules to determine whether a message is spam, and adds special headers if it is.
  4. Procmail takes these modified messages from spamassassin and continues processing them in the usual way - which in this case involves writing everything into the standard mbox file.
  5. When I tell my mail client to retrieve mail, it will read them from the mbox file. One filter rule takes all messages marked by spamassassin as spam, marks them as read and moves them to a dedicated "Junk" folder, leaving only "valid" mails in my Inbox.
  6. If any spam messages manage to trick spamassassin and make it to my Inbox, I simply move them into a special folder "Junk - uncaught". At the end of each day, a special process runs on this folder, which allows spamassassin to "learn from its mistakes", becoming more accurate every time.

Setting up Mozilla

Mozilla supports retrieving mail from an mbox file, but this option is not documented. To create such an email account, first create a normal POP3 account, then quit from Mozilla and find the user preferences file. The file is called "prefs.js" and it"s found somewhere in the hidden ".mozilla" or ".netscape" directories in your home directory. The easiest way to find it is to check the "Mail & Newsgroup Account Settings", under "Server Settings" in the POP3 account you can see the Local directory at the bottom. The prefs.js file is usually in the same directory as the "Mail" root folder.

Within this file, find the setting "mail.server.serverN.type/" (where N is a number), and change it from "pop3" to "movemail".

Apart from this, make sure that the directory containing the mbox file (/var/spool/mail) has the permissions "1777". This allows any user to create new files there, but existing files are protected from deletion or renaming. This is necessary because Mozilla will create a "lock file" to ensure exclusive access to your file before writing to it.

chmod 1777 /var/spool/mail

Note that Mandrake Linux will try to set the permissions back automatically to the default values through the msec program. To control this, edit the files /usr/share/msec/perm.*, find the line for /var/spool/mail, and set the permission to 1777.

<< 2003.12.02 Tue


Last updated on: Fri Dec 26 17:35:26 EST 2003

TOC

SourceForge.net Logo