Email Setup

Email Setup

Most users think email is simple. This page outlines my (rather complicated) email setup. The basic idea is that I use getmail to download my emails from a POP server. Getmail downloads these emails and sends them to procmail, which then forwards the emails to folders depending on their attributes (and the user supplied conditionals). Finally the emails end up in the users Maildir directory, from which they can be viewed using a mail reader such as mutt.

There are a few different types of mailbox formats, most notably mbox and Maildir. I use Maildir, mostly for arbitrary reasons. The Wikipedia and 'man mbox' are a good places to start reading about the differences.


Getmail is the program I use to receive my email from a pop server. To add an account, I put a file in ~/.getmail (I will refer to it as ~/getmail/file for this section) with information such as the following.

read_all = false
delete = false

type = SimplePOP3SSLRetriever
server = mail.mailserver.somewhere
username = username
port = 995
password = password

type = MDA_external
path = /usr/bin/procmail
unixfrom = true

Setting read_all and delete to false ensure that only new email messages are downloaded and that the messages are not deleted from the server. The middle section concerns the account information, and the last section informs getmail to send its mail to procmail. I can now download my mail by executing getmail -r ~/.getmail/file.


Bogofilter is a simple spam filter based on Bayesian networks. It learns the difference between spam and ham based a test set that is supplied by a human. A good way to start teaching your bogofilter is to run the command cat FOLDER/* | bogofilter -s on a FOLDER that contains all spam emails and cat FOLDER/* | bogofilter -n on a FOLDER that contains all ham (not spam) emails.


Procmail is a program that is used to sort email into different folders. I use it to send all incoming mail to bogofilter, and then putting the mail into the appropriate folder depending on whether it is spam or not. The following is my ~/.procmailrc.

# Variables

# Mail directory variables

# How to sort the email
  | /usr/bin/bogofilter -p -e
  * ^X-Bogosity:.(Spam|Yes)
  * ^X-Bogosity:.(Ham|Unsure|No)
   :0 c

The first sections set some variables. The only confusing part is that the paths (INBOX, SAVE, etc.) use mbox format if there is no trailing slash, and Maildir if there is a trailing slash. I have a trailing slash because I am using Maildir format.

The last section sends the email to bogofilter and then sorts the mail depending on the results (whether the mail is spam or ham). If it is spam, it is only put into the SPAM folder. If it is ham (not spam), then it is placed in both ARCHIVE and INBOX.