Adverts

Introduction

The Courier SMTP server has the ability to deliver mail to a users maildir on it's own but often it is useful to employ the services of another program in order to filter the mail before it gets to the mail folders. There are numerous reasons why you may want to do this but the two most important from my point of view are dealing with spam and not needing to set up filtering rules on every mail user agent I use.

Courier with Maildrop 

Ensure that you have the courier-maildrop package installed and then set up the courier smtp server to use maildrop to deliver mail. This is done by opening the file /etc/courier/courierd and changing the DEFAULTDELIVERY setting to DEFAULTDELIVERY="| usr/bin/maildrop" and then restarting courier-mta.

Maildrop Filter File

Filtering can be used at both a global and per user level. Globally it is set up in the file /etc/courier/maildroprc and locally it is set up by creating a file in the root of a user account called .mailfilter. I will not deal with global filtering much in this article as it is mainly only useful for spam filtering which is covered in another article.

The users .mailfilter file must have permissions of 600 or maildrop will issue an error and refuse to deliver mail. If there is a syntax error in the file maildrop will also refuse to deliver mail so if mail suddenly stops arriving check this first.

Blah blah... Sorry I'll get round to writing this section later.... 

References

Work In Progress...

This page is a combination of two pages that I accidently wrote on roughly the same topic. The stuff below is yet to be integrated with the stuff above. 

Filtering email is fairly easy now and most mail clients support some sort of filtering with many now also supporting spam filtering, however, there is a slight problem if you use multiple mail clients. The problem is that you ahve to set up your filtering rules seperatly on each and everyone which can become seriously boring seriously quickly (it's easy to end up using 3 different clients - two at home (one for each OS) and another at work (where you check you home email using your IMAP server)).

This page will show you how to set up the Maildrop MDA (Mail Delivery Agent) with the Courier mail suite so that filtering is done server side. A mail delivery agent handles the final delivery of email to the user but it's primary role in life is to apply filtering and sorting to the mail. The only down side of this approach is that the mail filters themselves aren't quite as easy to set up as they are in mail clients (you need to use a text editor for a start and learn a filtering language) but the extra effort should be worth it. I have assumed that you have a working Courier install.

A verison of Maildrop is typically installed with the Courier mail suite automatically as it is a dependency of sqwebmail. If you don't have sqlwebmail installed there is a seperate package that allows you to install maildrop. I think the difference is that the seperate package will take over all mail deliveyr on your system where as the courier one deals with only the courier packages.

Making Courier Use Maildrop

The first step is to get the courier-mta using maildrop. This is really easy when you know how. Finding out how to do it though is non-trivial. Edit the file /etc/courier/courierd so that the DEFAULTDELIVERY instruction is:

DEFAULTDELIVERY="| /usr/bin/maildrop"

Create Required Files

Create the file .mailfilter and set it's permissions to read/write user only (failure to set the permissions correctly will stop maildrop from working).

mkdir $HOME/.mailfilter
chmod 600 $HOME/.mailfilter

This is the file that will contain all your filtering rules. Depending on your set up you will also optionally need to create a the files $HOME/.courier and $HOME/.courier-default. These files must also have permissions of 600 and have the contents:

| /usr/bin/maildrop

The two courier files are only needed if you have mailbox attributes set up for the user. This is the case if you are using aliases otherwise you can rely on the DEFAULTDELIVERY setting.

Setup Filter Rules

I would be seriously duplicating effort if I gave a full tutorial on how to write maildrop rules here. There is plenty of information on the Internet about how to write rules. I found the resources as Gentoo wiki and the man page (man maildropfilter) to be quite good. A very quick way of testing whether you maildrop is configured though is to place just the rule

to "./Maildir/.test"

in your .mailfilter file and create a test folder under your Inbox. This should then cause all your mail to get sent to this test folder. A word of warning - you need to make sure that both your IMAP server and your MUA realize that mail can be delivered to folders other than the default Inbox. This is not normally a problem with the IMAP server but it can be a problem with Thunderbird. As of version 1.0.2 of Thunderbird there isn't a (GUI) setting for make it check every folder. There is, fortunatly, a minor tweak you can make that will force it to check all folders.

Make Thunderbird Check All Folders for New Mail

You need to make a change to your prefs.js file by hand (yuck - this feels like I'm making a registry change in windows, oh well) so shut down Thunderbird. First locate the file. It will be somewhere like .mozilla-thunderbird/default/prefs.js. It says at the top of the file "don't modify this file" which I take to mean "make a back up copy of this file before messing with it". There is a somewhat confusing write up here (the Tools > Advanced Settings doesn't exist in my version of Thunderbird). Add the line

user_pref("mail.check_all_imap_folders_for_new", true); 

to the bottom of the prefs.js file (you did make a back up didn't you :o). Now restart Thunderbird, it should now check all folders. Quite why this isn't the default I don't know as it seems to work perfectly. I suspect that the implimentation is a little duff and therefore only suitable for use on a small scale. You can find out more about hidden preferences in Firefox and Thunderbird here

Swtich to KMail

There was a gushing review of KMail here but it got a little out of hand and deserved it's own page so I moved it here.

Resources

 

Adverts

Donate and Help

Please support this site and
Bandwidth doesn't grow on trees y' know :o)

Adverts

Get Adsense