The MailDir Email Storage Format: Understanding New, Cur, & Tmp
-
If you work with email servers, you likely have encountered the MailDir email format, even if you didn't know what it was. MailDir is an industry standard format for storing email messages in folders as individual files. It's one of the most common and simplest email storage formats that leverages the operating system's filesystem and really exposes just how much email MDAs operate like speciality file servers.
Common MDAs include Dovecot, Courier, and Cyrus.
MailDir is primarily a folder layout for containing mail files. It is decently straightforward, although it can vary from server to server so there is always a bit of "convention" vs. configuration that you have to determine on any given system. Most importantly, there are three folders that we find at the bottom layer of a MailDir directory: new, cur, and tmp. What do these three folders do?
new: This folder holds new mail that has been received by the system but that has not yet been read by any type of agent. This would be what we think of as unread messages in the inbox.
cur: This folder stands for current and this is where messages are stored after an email agent has read, but not deleted, the messages. So this folder holds the read messages in the inbox.
tmp: This is the temp folder where temporary files are stored, such as those in the process of being delivered.