Maildir
From Wikipedia, the free encyclopedia
Maildir is a format for an e-mail spool that does not require file locking to maintain message integrity because the messages are kept in separate files with unique names. A Maildir is a directory (often named Maildir) with three subdirectories named tmp, new, and cur. The subdirectories should all reside on the same filesystem.
Contents |
[edit] Operation
The process that delivers an e-mail message writes it to a file in the tmp directory with a unique filename. The current algorithm for generating the unique filename for the message is described at [1]. To ensure uniqueness, a number of pseudo-random parameters are included in the name.
The delivery process stores the message in the maildir by creating and writing to tmp/unique, and then hard-linking this file to new/unique. Finally, the delivery program unlinks the file in tmp - although not formally required by the specification to do so. This sequence guarantees that a maildir-reading program will not see a partially-written message, as MUAs never look in tmp.
When the mail user agent process finds messages in the new directory it moves them to cur (using the same link then unlink strategy) and appends an informational suffix to the filename before reading them. The information suffix consists of a colon (to separate the unique part of the filename from the actual information), a '2', a comma and various flags. The '2' specifies, loosely speaking, the version of the information that follows the comma. '2' is the only currently officially specified version, '1' being an experimental version. One can only assume that it was used while the Maildir format was under development.
[edit] Issues with lockless operation
Daniel J. Bernstein, the author of qmail, djbdns, and various other software, designed Maildir to be safely writable by multiple concurrent writers without any form of locking, even over NFS. To a large extent this works pretty well, but he didn't take into account the real world limitations of today's filesystems. The problem is that readdir() system call doesn't guarantee that it returns all the files in a directory if the directory is being modified at the same time. In practise this means that if one process updates a message's flag, another process's readdir() call might skip a file, which causes the process to believe the message was deleted. When the process gets around to listing the messages again, the "deleted" message suddenly appears again. Some mail-accessing programs layer their own locking on top of Maildir in an attempt to prevent these kind of problems. Dovecot, for example, uses its own non-standard locking with Maildir.
[edit] Maildir++
Maildir++ is an extension to the Maildir format. In addition to the normal Maildir structure described above, Maildir++ directories contain subdirectories with names that start with a '.' (dot) that are also Maildir++ folders. This extension is technically a violation of the Maildir specification, which provides an exhaustive list of the possible contents of a maildir.
[edit] Software that supports Maildir
[edit] Mail servers
- Dovecot IMAP server
- BincIMAP, a Maildir-only IMAP server
- Courier Mail Server, where Maildir++ format was invented
- OfflineIMAP provides syncing between IMAP servers and local Maildir mail folders http://darcs.complete.org/offlineimap/
- Exim
- Postfix
- Qmail, where Maildir format was invented
- getmail, a maildir-aware mail-retrieval and delivery agent
- XMail, an open source cross-platform (*nix and Windows) SMTP and POP3 server
[edit] Delivery agents
- Procmail
- Safecat, includes a script called maildir for use in pipelines
- Maildrop, delivery agent which allows for custom filters and actions
[edit] Mail readers
- Cone a curses-based mail reader
- KMail a KDE mail reader
- Mutt and Mutt-ng
- Novell Evolution a GNOME mail client resembling Outlook
- Sylpheed-claws through a plugin
The Maildir standard can not be implemented without modification on systems running Microsoft Windows, which does not tolerate the inclusion of colons in filenames.