Maildir worksheet

For scalability, we are going to arrange for exim to deliver all local mail in Maildir format. This creates a subdirectory called "Maildir" in the user's home directory, which in turn contains three subdirectories: new, cur and tmp. Messages are written into tmp, moved to new when delivery is complete, and moved to cur when read. Each message has a long filename based on the hostname and the time of day.

Because each message is stored in a separate file, it is much faster for the pop3 daemon to start up every time a user connects. It also allows for safe delivery onto a shared (NFS) disk backend.

Remember: when creating new "E-mail" accounts on your system, you probably don't want your users to actually be able to login to Unix using ssh or telnet. To disable this, create their accounts with a nonexistent shell.

# useradd -m -s /nonexistent username

Reconfigure exim for Maildir local delivery

Edit /usr/exim/configure, find the local_delivery transport and modify it as follows:

local_delivery:
  driver = appendfile
  directory = $home/Maildir
  maildir_format
  delivery_date_add
  envelope_to_add
  return_path_add
# group = mail
# mode = 0660

Optionally you could add further parameters to this transport which let you impose quotas on your users, for example to limit all users to 10 megabytes of storage each:

  maildir_tag = ,S=$message_size
  quota_size_regex = ,S=(\d+)
  quota = 10M
  quota_warn_threshold = 90%

Remember to HUP your exim daemon. Now test out your new configuration by delivering to some local account on your machine:

$ /usr/exim/bin/exim -bt localuser
localuser@pcnn.taller.nsrc.org
  router = localuser, transport = local_delivery
$ /usr/exim/bin/exim localuser
Here is a test
.
$ cd /home/localuser/Maildir
$ ls
cur     new     tmp
$ ls new
102078119.7969.pcnn.taller.nsrc.org,S=426
$ cat new/*
Return-path: <root@pcnn.taller.nsrc.org>
...
Here is a test

Note: once you have changed to Maildir delivery, you will find that your MUA (which looks in /var/spool/mail) will no longer see your incoming mail. How to fix this depends on your MUA. For example:

mutt
In /etc/Muttrc put:
set spoolfile="~/Maildir/"