Server side mail filtering

When you get a lot of mail, and go on vacation, you usually pull in all that mail over your expensive roaming 3G connection.

I use filtering to make sure certain mails end up in the right folder. I usually don't want to read all mails that come from mailinglists. You can use filtering from within your mail client  and that works well. That has one huge disadvantage : Your mail client needs to pull in at least the headers to see if it matches filtering. Not nice if you're for example subscribed to the LKML.

So.. How do you handle this, without all kinds of mailclient plugins ? The answer : Service side filtering. I use Maildir as my mailbox format, and if you still use mbox : See this article to migrate. I use maildrop as my mail delivery agent, since it has filtering capabilities.

I assume that you've told your MTA (Postfix, Sendmail) to use it : If not, you'll end up debugging why it isn't filtered, and at the end, you'll find out it isn't even called.

When maildrop works, it's time to start filtering. Configuring is done using the .mailfilter file in your homedir, or a .mailfilters directory in your homedir. A small part of the one I'm using right now :

It's pretty simple : It specifies a logfile (relative starting at our homedir). After them, a regexp, and a action. I wrap the actions in an exception statement, so that if the move fails, we don't bounce to the sender (which in case of a mailinglist, will mos likely result in a unsubscribe). In above examples, it will filter messages from LinkedIn or the OSGi mailinglist.

Look at the headers to see a common header in messages that belong together. You can't assume things, especially not with mailing lists.

If you also run SpamAssasin, you can filter on for example on the X-Spam-Status header. Example :

Happy filtering !!