HOME


mail setup

overview

getmail

getmail is run by cron at 5 minute intervals to fetch mail from various servers. Since it needs to deliver to different users it has to be run as root (it drops to the recipient user's ID when delivering their mail). Normally getmail's config files would be in the user's ~/.getmailrc directory, and the config files used by getmail running as root are in my own directory. They could (and probably should) be elsewhere: the location is specified in the getmail invocation.

The command to run getmail is like:

/usr/bin/getmail -q --getmaildir=/home/foo/.getmail -d --rcfile getmailrc.account1 -d --rcfile getmailrc.account2 -d --rcfile=getmailrc.account3 ... etc ...

getmail configuration files

Retrieving mail for a single user from a host such as NTL is straightforward. The getmailrc file looks like:

[retriever]
type = SimplePOP3Retriever
server = pop.ntlworld.com
username = user.name
password = password

[destination]
type = Maildir
path = ~user/Maildir/
user = user

user.name and password are the user's NTL credentials

user is the user's Unix username

The final (user = ) line is not strictly necessary: getmail would default to that since it is delivering to user's directory (and if getmail were being run as user rather than as root it would not even have to infer what user ID it was using to deliver mail).

multidrop versus multiguess

We have a couple of domains hosted (at lilio.com) which receive mail for more than one of us. The host (lilio) end is configured to deliver all mail for a domain to a single user. This means that mail for, say, alice@example.com and bob@example.com will all go to alice. The pop host identifies who it is for by adding a field such as (in lilio's case) Envelope-to:. This is straightforward enough until an email is addressed to both alice and bob. In this situation a hosting server can do one of two things: a true multidrop server would deliver two copies of the email, one with
    Envelope-to: alice@example.com

and another with
    Envelope-to: bob@example.com.

Lilio (and most other common hosts, apparently) doesn't do this: it delivers one email with
    Envelope-to: alice@example.com, bob@example.com.

Getmail can deal with this in its multiguesser configuration mode: when it sees an email addressed this way it puts one copy in alice's mail store and another copy in bob's.

The getmailrc file for retrieving mail from a non-multidrop host serving multiple users looks like:

[retriever]
type = SimplePOP3Retriever
server = pop.example.com
username = alice_username
password = alice_password

[destination]
type = MultiGuesser
default = [alice]
locals = (
    ('alice@example.com', '[alice]'),
    ('bob@example.com', '[bob]'),
)

[alice]
type = Maildir
path = ~alice/Maildir/
user = alice

[bob]
...etc...

See also: getmail documentation at pyropus.ca

dovecot

dovecot runs as a daemon. After making any changes to its config one can restart it by (as root)

/etc/init.d/dovecot restart

With its default configuration (in /etc/dovecot/dovecot.conf) it will auto-detect where a user's mail is "by looking at ~/Maildir, /var/mail/username, ~/mail and ~/Mail in that order" (according to http://wiki.dovecot.org/MailLocation). Thus if a user has a ~/Maildir Dovecot's default configuration will work, but it is recommended to set this explicitly in the config file thus:

mail_location = maildir:~/Maildir

exim

exim is the standard mail transfer agent on Debian. Other systems might use sendmail or other agents. Its role in my mail setup is delivering system mail - from cron jobs etc - to me (as the designated user to receive such messages). The command

dpkg-reconfigure exim4-config

allows one to specify whether exim delivers to Maildirs or mail spools (in /var/mail/user).


HOME