« May 2007 | Main | November 2007 »

August 2007 Archives

August 10, 2007

Cyrus + SpamAssassin + POPFile = Happiness

Sorting mail with the POPFile IMAP module is very easy, training POPFile via IMAP is also easy. You might sometimes experience slight problems though, because your mail client will see messages in your INBOX before POPFile sees them. If these are spam, e.g., you get a new mail alert only to see POPFile move such messages to your spam folder as soon as you have a look.

But who says that new mail must be delivered to your INBOX? If your IMAP server is cyrus (or any other IMAP server that supports sieve scripts), you can change that and have your mail delivered to another folder. You then have POPFile monitor this other folder and move good messages to your INBOX while it sorts spam to your spam folder and mailing list emails to your mailing lists folder.

Here's how to do it:

1. Edit the sieve rules of your server. There are several ways to do that: from the command line using sieveshell and from the web using tools like the SquirrelMail avelsieve plugin or websieve.

What you need to get started is one single rule that moves all incoming mail to a folder of your choice that is not the INBOX. For example, you could create a folder named 'Incoming' and have sieve deliver all messages to that folder. Here's the corresponding sieve script:

require ["fileinto"];
fileinto "Incoming"; stop;

That's pretty easy. As you will have guessed, the fileinto statement files all messages into the Incoming folder. The stop statements simply stops further rule execution.

2. Now setup POPFile to watch the Incoming folder instead of the INBOX. Simply load POPFile's Configuration tab and make the "Watched folder no1" the Incoming folder. (If you have just created that folder, POPFile might not have noticed it yet; simply click the 'Refresh folders now!' button and the folder will appear in the folders drop-down).

3. Set the output folder of one of your buckets to 'INBOX'.

4. Hit apply and enjoy.

Your mail client will never be distracted again by messages that it isn't supposed to see anyway.

Where does SpamAssassin enter the picture? Well, if you server is also running SpamAssassin you can use sieve scrpting to get rid of spam immediately. You won't even have to bother POPFile with that crap. To have everything that SpamAssassin thinks is spam to a folder named 'spam', simply add a line to the above script. The result should look like this:

require ["fileinto"];
if header :is "X-Spam-Flag" "YES" { fileinto "spam"; stop;}
fileinto "Incoming"; stop;

Easy.

About August 2007

This page contains all entries posted to Manni's blog in August 2007. They are listed from oldest to newest.

May 2007 is the previous archive.

November 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.