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 does not need to read through the mbox file to count the messages in the mailbox. 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/local/etc/exim/configure, find the local_delivery transport and modify it as follows:

  driver = appendfile
  directory = $home/Maildir
# 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%

(Aside: this quota mechanism relies on users not meddling with the quota information which is stored within their maildir; in other words, users with shell access would be able to bypass their quota if they knew what they were doing)

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

$ /usr/local/sbin/exim -bt localuser
  router = localuser, transport = local_delivery
$ /usr/local/sbin/exim localuser
Here is a test
$ cd /home/localuser/Maildir
$ ls
cur     new     tmp
$ ls new,S=426
$ cat new/*
Return-path: <>
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:

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