Bookmarks

Maildir

A mailbox layout on disk in which each message is a separate file inside the mailbox directory.

Also: Maildir format, Maildir mailbox

checked 9 Nov

All terms

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

DirectoryContents
tmpa message that is still being written
newdelivered messages the user has not yet seen
curmessages 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.

textFlags in the name: F is flagged, S is seen
Maildir/├── tmp/├── new/1276528487.M364837P9451.kurkku└── cur/1276533073.M242911P3632.kurkku:2,FS

In 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 pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • MDAmail delivery agent

    An MDA is the program that places a message in a mailbox; Maildir is the format in which it is stored there.

In depth in the references

where the topic is covered in detail