Codingdomain.com

Automatic mail processing

Background

In order to process e-mail automatically, a different approach is taken. The approach differs from the common "POP3 way" of doing things. This background compares the two methods.

The normal way

Usually, people use an e-mail client to download POP3 mail directly. Messages are downloaded when the e-mail client starts.

POP3 Download
Mail Client
<-- download
Internet Server

Often the client has it's own methods for filtering and storing messages.

The automatic way

To download the messsages automatically, a chain of tools will be used. Each tool performs a different task what it does best. We'll use individual tools to filter, retreive and store the e-mail. This example displays how the e-mail messages will be downloaded:

Automatic method
Mail Folder
<-- store
'maildrop'
<-- filter
'getmail'
<-- download
Server

Getmail is a small utility that can download and forward an e-mail message from POP3 and IMAP servers. It passes the e-mail message to Maildrop, which will store the message in your mailfolder. Maildrop can be used to filter and sort the messages, and detect spam.

This approach keeps all options open on how you like to process the e-mail, and how the e-mail will be accessed later. For example, getmail can be invoked at certain intervals in order to download the e-mail messages regulary.

Now, to access the e-mail folder, we use an IMAP server to make this network-transparent.

Reading the mail
Mail Client
access imap -->
'courier-imap'
read -->
Mail Folder

At the end of the chain you end up using the same e-mail client, but you can replace that tiny piece of the chain with any other IMAP-capable client. Such client can include Outlook Express from your Windows computer, or a webmail portal supporting IMAP.

This is a major advantage, as IMAP enables each e-mail client to view the same messages, including the ones read in another client, or read with webmail.

Mbox mailboxes vs Maildir mailboxes

Courier-IMAP does not use the common UNIX mailfiles (AKA "Mbox" or "Mailbox" format). Those files typically created for each user in /var/spool/mail. It uses Inboxes in the Maildir format.

The Mbox format stores all e-mail messages in one single file, which makes it less efficient for large mailboxes. The Maildir format stores each message in a different file. This solution is therefore faster, safer, and allows multiple access to the e-mail messages.

Some e-mail tools allow both Mbox and Maildir formats. Usually you need to terminate the mailbox path with a final / to indicate you'd like to use the Maildir format instead.

Next part