In Maildir, a mailbox is a directory and a message is a file. Delivery and reading therefore do not interfere with each other and no locking is needed: while a mail client reads or deletes messages, the server can safely add new ones.
Directory layout
| Directory | Contents |
|---|---|
tmp | a message that is still being written |
new | delivered messages the user has not yet seen |
cur | messages the client has already noticed; flags are stored in the file name |
The server first writes the whole message to tmp, then moves it to new, so a reader never sees a half-written message. The file name is unique: it is built from the time, a delivery identifier (usually microseconds and the process ID) and the host name. When a client opens a message, the file moves to cur and the suffix :2, and flag letters are appended to its name.
Maildir/├── tmp/├── new/1276528487.M364837P9451.kurkku└── cur/1276533073.M242911P3632.kurkku:2,FSIn Bernstein’s specification the flags are P (passed), R (replied), S (seen), T (trashed), D (draft) and F (flagged), listed in alphabetical order.
Advantages and limitations
- No locking and no shared file: a message can be added, changed or deleted without touching the others.
- Safe for simultaneous access by several programs and over the NFS network file system.
- Dovecot describes the format as suitable mainly for small installations and maintains it without new optimisations.
The format appeared with the qmail mail server in the mid-1990s and was described by D. J. Bernstein.
Sources
the term is written from these pagesVerified 9 Nov