getmail
gets mail from our hosting providers (via pop) and
puts it into the Maildirs of local
usersdovecot
serves mail via imap from users' Maildirs to their
mail clientsexim
delivers system mail to my Maildirgetmail
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
...
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 multiguessWe 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,
Lilio (and most other common hosts, apparently) doesn't do this:
it delivers one email with Getmail can deal with this in its multiguesser
configuration mode: when it sees an email addressed this way it puts
one copy in |
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...
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
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
).