mbox(5)
๐ mbox(5) ๐
okay bestie, so this is the manual page for mbox(5) โ the format for mail message storage. no literally, that's what it is. let's get into it ๐
โจ NAME โจ
mbox โ the format for storing mail messages, and honestly it's giving vintage Unix realness ๐
๐ธ DESCRIPTION ๐ธ
so this whole document is describing the format that Unix hosts have traditionally used to store mail messages locally. mbox files typically live in the system's mail spool, under various names in users' Mail directories, and under the name mbox in users' home directories. iykyk ๐๏ธ
an mbox is a text file containing an arbitrary number of e-mail messages. each message consists of a postmark, followed by an e-mail message formatted according to RFC822, RFC2822. the file format is line-oriented. lines are separated by line feed characters (ASCII 10). fr fr.
a postmark line consists of the four characters "From", followed by a space character, followed by the message's envelope sender address, followed by whitespace, and followed by a time stamp. this line is often called From_ line. iconic behavior tbh ๐ซถ
the sender address is expected to be addr-spec as defined in RFC2822 3.4.1. the date is expected to be date-time as output by asctime(3). for compatibility reasons with legacy software, two-digit years greater than or equal to 70 should be interpreted as the years 1970+, while two-digit years less than 70 should be interpreted as the years 2000-2069. software reading files in this format should also be prepared to accept non-numeric timezone information such as "CET DST" for Central European Time, daylight saving time. no cap, that's the rule ๐ฐ๏ธ
example:
>From example@example.com Fri Jun 23 02:56:55 2000
in order to avoid misinterpretation of lines in message bodies which begin with the four characters "From", followed by a space character, the mail delivery agent must quote any occurrence of "From " at the start of a body line. periodt.
there are two different quoting schemes, bestie:
- the first (
MBOXO) only quotes plain"From "lines in the body by prepending a>to the line - the second (
MBOXRD) also quotes already quoted"From "lines by prepending a>(i.e.">From ",">>From ", ...)
the later has the advantage that lines like
>From the command line you can use the '-p' option
aren't dequoted wrongly as a MBOXRD-MDA would turn the line into
>>From the command line you can use the '-p' option
before storing it. besides MBOXO and MBOXRD there is also MBOXCL which is MBOXO with a "Content-Length:"-field with the number of bytes in the message body; some MUAs (like mutt(1)) do automatically transform MBOXO mailboxes into MBOXCL ones when ever they write them back as MBOXCL can be read by any MBOXO-MUA without any problems. slay ๐
if the modification-time (usually determined via stat(2)) of a nonempty mbox file is greater than the access-time the file has new mail. many MUAs place a Status: header in each message to indicate which messages have already been read. ๐
๐ LOCKING ๐
since mbox files are frequently accessed by multiple programs in parallel, mbox files should generally not be accessed without locking. this is the part where you pay attention bestie, fr fr โ ๏ธ
three different locking mechanisms (and combinations thereof) are in general use:
fcntl(2)locking is mostly used on recent, POSIX-compliant systems. use of this locking method is, in particular, advisable ifmboxfiles are accessed through the Network File System (NFS), since it seems the only way to reliably invalidate NFS clients' caches.flock(2)locking is mostly used on BSD-based systems.- Dotlocking is used on all kinds of systems. in order to lock an
mboxfile namedfolder, an application first creates a temporary file with a unique name in the directory in which thefolderresides. the application then tries to use thelink(2)system call to create a hard link namedfolder.lockto the temporary file. the success of thelink(2)system call should be additionally verified usingstat(2)calls. if the link has succeeded, the mail folder is considered dotlocked. the temporary file can then safely be unlinked. ๐
in order to release the lock, an application just unlinks the folder.lock file. easy peasy.
if multiple methods are combined, implementors should make sure to use the non-blocking variants of the fcntl(2) and flock(2) system calls in order to avoid deadlocks. deadlocks are not the vibe ๐
if multiple methods are combined, an mbox file must not be considered to have been successfully locked before all individual locks were obtained. when one of the individual locking methods fails, an application should release all locks it acquired successfully, and restart the entire locking procedure from the beginning, after a suitable delay. like, reset the whole thing, no shortcuts ๐ซถ
the locking mechanism used on a particular system is a matter of local policy, and should be consistently used by all applications installed on the system which accessmboxfiles. failure to do so may result in loss of e-mail data, and in corruptedmboxfiles. this is the serious part, bestie โ don't skip the locking, okay? ๐ญ
๐ FILES ๐
/var/spool/mail/$LOGNAMEโ$LOGNAME's incoming mail folder. your main character inbox ๐$HOME/mboxโ user's archived mail messages, in his$HOMEdirectory.$HOME/Mail/โ a directory in user's$HOMEdirectory which is commonly used to holdmboxformat folders. it's giving organized queen energy ๐
๐ SEE ALSO ๐
mutt(1), fcntl(2), flock(2), link(2), stat(2), asctime(3), maildir(5), mmdf(5), RFC822, RFC976, RFC2822
go read those if you're hungry for more, i'm obsessed with cross-referencing ๐ฆ
โ๏ธ AUTHOR โ๏ธ
Thomas Roessler <roessler@does-not-exist.org>, Urs Janssen <urs@tin.org>
legends, honestly ๐
๐ HISTORY ๐
the mbox format occurred in Version 6 AT&T Unix. a variant of this format was documented in RFC976. so it's been around, like, forever. vintage but still relevant, we love a classic ๐
okay that's the whole page bestie! this was the mbox(5) manual from the Unix manual pages, dated February 19th, 2002. go forth and handle your mail files responsibly, and remember: lock before you write, or you'll have a bad time ๐ญโจ๐
๐ฆ where this page comes from
- alpine 3.24: mutt-doc 2.3.2-r1 ยท GPL-2.0-or-later
- arch rolling: mutt 2.4.3-1 ยท GPL-2.0-or-later
- debian bookworm: mutt 2.2.12-0.1~deb12u1 ยท GPL-2.0-or-later
- debian bookworm: mutt 2.2.9-1+deb12u1 ยท GPL-2.0-or-later
- debian trixie: mutt 2.2.13-1+deb13u1 ยท GPL-2.0-or-later
- debian trixie: mutt 2.2.13-1+deb13u2 ยท GPL-2.0-or-later
- nixos 26.05: mutt 2.3.3
- nixpkgs unstable: mutt 2.4.3
- ubuntu noble: mutt 2.2.12-0.1build4 ยท GPL-2.0-or-later
- ubuntu questing: mutt 2.2.13-1
- ubuntu resolute: mutt 2.2.13-1build2 ยท GPL-2.0-or-later
- ubuntu stonking: mutt 2.4.1-1 ยท GPL-2.0-or-later
- Copyright (C) 2000 Thomas Roessler <roessler@does-not-exist.org>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms