Codingdomain.com

Automatic mail processing

Download chain setup

Maildrop

Maildrop is the essential part in the downloading chain.

For new, keep things simple, and just configure the basic settings.

Maildrop filter file: ~/.mailfilter
# Configuration file for maildrop

# Global settings
MAILBOX="$HOME/.maildir"
DEFAULT="$MAILBOX"

logfile "$HOME/.getmail/maildrop.log"

This basic configuration instructs maildrop to save all messages in the ~/.maildir/ folder. The file ~/.getmail/maildrop.log will be used to monitor the status of Maildrop. If anything went wrong, it can be found here.

The filtering language of Maildrop uses regular expressions, which allows you to build powerfull filter criteria. Below are some examples you can use:

Getmail

Getmail does the actual downloading of e-mail. It will be configured to deliver the messages to Maildrop.

To store the Getmail settings, create the hidden ~/.getmail/ folder:

Create the getmail folder:
mkdir ~/.getmail

The details of the configuration differ between version 3 and 4 of Getmail.

getmail-3

With getmail-3, multiple e-mail accounts can be added to the same file. Each account simply uses a new section in the file. These configurations can be used for getmail-3:

Getmail-3 configuration: ~/.getmail/getmailrc
# Configuration file for getmail.

[default]
verbose      = 1                      # status information in shell
readall      = 1                      # fetch all messages
delete       = 1                      # delete mail from server
postmaster   = "|/usr/bin/maildrop"   # default action: pass to maildrop

message_log  = "~/.getmail/getmail.log"


[Name for the account]
server   = "pop3 server hostname"
username = "your e-mail address"
password = "your password"

etc...

In case something goes wrong, the defined message log file (~/.getmail/getmail.log) can be accessed to find the cause.

There are some other interesting settings that can be used. Using these settings is optional:

Alternative getmail-3 settings:
delete       = 0                      # don't delete now
delete_after = 10                     # delete after 10 days
postmaster   = "~/.maildir/"          # avoid maildrop, delever directly

These settings leave the messages on the server for 10 days, and deliver the e-mail to the maildir directly.

getmail-4

The configuration for getmail-4 is a little different, and you need to create a separate file for each account. The name of the default section is also different; it's called "options" now. If you upgrade to version 4 you need to re-write your configuraiton.

With just one account, it's still possible to use just a single ~/.getmail/getmailrc file. In my situation, I need to use multiple configuration files. I'll avoid the generic getmailrc file, to make sure it catches my eye when I start getmail directly.

For my Hotmail e-mail, I use a ~/.getmail/rc_vdboor@hotmail file, and e-mail for Codingdomain is delivered with another file called ~/.getmail/rc_vdboor@codingdomain.

Here is an example for getmail-4:

Getmail-4 configuration: ~/.getmail/<your rc file>
# Configuration file for getmail.

[options]
verbose      = 1
readall      = 1
delete       = 1
message_log  = ~/.getmail/getmail.log

[retriever]
type     = SimplePOP3Retriever
server   = pop3 server name
username = your e-mail address
password = your password

[destination]
type = MDA_external
path = /usr/bin/maildrop
unixfrom = True

As you'll might notice, it's no longer possible to use comments at the end of a line, or use quotes in the values like getmail-3 supports. This is an unfortunate side effect of the switch getmail made to the official python parser, and I really reget this.

Protecting the passwords

Once the files are finished, there is one thing left to do. The passwords need to be protected from unwanted access by other system users. This can be done with a normal chmod command.

Protect your passwords:
chmod 700 ~/.getmail/
chmod 600 ~/.getmail/*

Next part

blog comments powered by Disqus