HOME

TheInfoList



OR:

Mbox is a generic term for a family of related
file format A file format is a Computer standard, standard way that information is encoded for storage in a computer file. It specifies how bits are used to encode information in a digital storage medium. File formats may be either proprietary format, pr ...
s used for holding collections of
email Electronic mail (usually shortened to email; alternatively hyphenated e-mail) is a method of transmitting and receiving Digital media, digital messages using electronics, electronic devices over a computer network. It was conceived in the ...
messages. It was first implemented in Fifth Edition Unix. All messages in an mbox mailbox are concatenated and stored as
plain text In computing, plain text is a loose term for data (e.g. file contents) that represent only characters of readable material but not its graphical representation nor other objects ( floating-point numbers, images, etc.). It may also include a lim ...
in a single file. Each message starts with the four characters "From" followed by a space (the so-called "From_ line") and the sender's email address. RFC 4155 defines that a UTC timestamp follows after another separating space character. A format similar to mbox is the MH Message Handling System. Other systems, such as
Microsoft Exchange Server Microsoft Exchange Server is a mail server and calendaring server developed by Microsoft. It runs exclusively on Windows Server operating systems. The first version was called Exchange Server 4.0, to position it as the successor to the relat ...
and the Cyrus IMAP server, store mailboxes in centralized databases managed by the mail system and not directly accessible by individual users. The
maildir The Maildir e-mail format is a common way of storing email messages on a file system, rather than in a database. Each message is assigned a Computer file, file with a unique name, and each mail folder is a file system directory containing these fil ...
mailbox format is often cited as an alternative to the mbox format for networked email storage systems.


Mail storage protocols

Unlike the Internet protocols used for the exchange of email, the format used for the storage of email has never been formally defined through the RFC standardization mechanism and has been entirely left to the developer of an email client. However, the
POSIX The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
standard defined a loose framework in conjunction with the
mailx mailx is a Unix utility program for sending and receiving mail, also known as a Mail User Agent program. Being a console application with a command syntax similar to ed, it is the POSIX standardized variant of the Berkeley Mail utility. See als ...
program. In 2005, the application/mbox media type was standardized as RFC 4155, which hinted that mbox stores mailbox messages in their original Internet Message (RFC 2822) format, except for the used newline character, seven-bit clean data storage, and the requirement that each newly added message is terminated with a completely empty line within the mbox database.


File locking

Because more than one messages are stored in a single file, some form of
file locking File locking is a mechanism that restricts access to a computer file, or to a region of a file, by allowing only one user or process to modify or delete it at a specific time, and preventing reading of the file while it's being modified or delet ...
is needed to avoid the corruption that can result from two or more processes modifying the mailbox simultaneously. This could happen if a network email delivery program delivers a new message at the same time as a mail reader is deleting an existing message. Various mutually incompatible mechanisms have been used by different mbox formats to enable message file locking, including fcntl() and lockf(). This does not work well with network mounted file systems, such as the Network File System (NFS), which is why traditionally Unix used additional "dot lock" files, which could be created atomically even over NFS. Mbox files should also be locked while they are being read. Otherwise, the reader may see corrupted message contents if another process is modifying the mbox at the same time, even though no actual file corruption occurs.


As a patch format

In
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
development, it is common to send patches in the
diff In computing, the utility diff is a data comparison tool that computes and displays the differences between the contents of files. Unlike edit distance notions used for other purposes, diff is line-oriented rather than character-oriented, but i ...
format to a
mailing list A mailing list is a collection of names and addresses used by an individual or an organization to send material to multiple recipients. Mailing lists are often rented or sold. If rented, the renter agrees to use the mailing list only at contra ...
for discussion. The diff format allows for irrelevant "headers", such as mbox data, to be added. Version control systems like git have support for generating mbox-formatted patches and for sending them to the list as emails in a thread.


See also

*
Maildir The Maildir e-mail format is a common way of storing email messages on a file system, rather than in a database. Each message is assigned a Computer file, file with a unique name, and each mail folder is a file system directory containing these fil ...
* MIX (email) * MH Message Handling System


References

{{reflist


Further reading


qmail mbox manual page

Internet Mail Consortium
– Standards body Email storage formats