Converters

What is an MBOX file, and which Mac apps use it

MBOX is four formats wearing one extension. Which variant your application wrote decides whether the next one can read it, and the file itself will not tell you.

13 min read

MBOX is not one format. Four incompatible variants share the extension. They disagree about how to mark where one message stops and the next begins. Nothing in the file announces which one you are holding. That is why an MBOX file opening perfectly in one application can arrive mangled or empty in another.

The good news is that one variant has effectively won. A two minute look inside a file will tell you whether yours is that one.

What an MBOX file contains

An MBOX file is plain text with messages concatenated end to end. The delimiter between them is a blank line followed by a line beginning with the word From and a space.

Nothing is compressed, whatever the word container suggests. There is no archive to unpack and no password to supply. Attachments sit inside the text as base64, the MIME encoding that turns binary into printable characters, which is why a mailbox with photographs in it produces a file far larger than the mail appears to warrant.

That works until a message body contains a line starting the same way. Write "From my point of view" at the start of a line and a parser cannot tell it from a new message.

From MAILER-DAEMON Fri Jul 8 12:08:34 2011
From: Priya <priya@example.com>
Subject: Lunch

Sounds good to me.
>From my point of view it was always going to work.

From MAILER-DAEMON Fri Jul 8 14:22:10 2011
From: Arjun <arjun@example.com>
Two messages. The lines at the far left with no colon are separators. The one inside the body carries a greater than sign so a parser does not mistake it for a third message. That mark is what the variants disagree about.

How to open an MBOX file on a Mac

Double clicking one achieves nothing useful. That is where most people start. macOS ships no viewer for the format. Quick Look cannot preview it and Finder treats it as an unknown lump.

What you wantRoute
Just read the messagesOpen it in TextEdit or any editor. Ugly, instant, no software needed
Read it properly, with threadingImport into Apple Mail or Thunderbird
Search a huge archiveA dedicated viewer, since importing a large file is slow

For the middle route, Apple Mail offers Import Mailboxes under File, where the source type for a bare file is Files in mbox format. Choosing the wrong source there is the most common reason an import brings in nothing.

Size is the practical limit, not the format. A Gmail archive from Takeout can run to many gigabytes. Importing one of those into a mail client is an afternoon rather than a minute. Nothing is wrong when it takes that long. If you only need to find a few messages, reading the file rather than importing it is the faster answer.

The four MBOX variants

Every difference between the variants is an answer to that one problem. Each solved it differently in a different version of Unix. None of those solutions can be detected reliably from outside. The naming scheme came later, in 1996, from Daniel J. Bernstein, Rahul Dhesi and others, describing formats that already existed and already disagreed.

VariantHow it handles From in a bodyWhere you meet it
mboxoEscapes it, but not reversibly. Content can be corruptedEarly Unix and Eudora
mboxrdEscapes From to >From and >From to >>From. Always reversibleThunderbird, qmail, most modern tools
mboxclAdds a Content-Length header. References disagree on whether it also escapesSystem V Unix, some older clients
mboxcl2Content-Length only, no escaping at allSystem V Unix, rare now

The middle row is the one that matters. Rahul Dhesi's fix works because the transformation runs both ways without ambiguity. That reversibility is why mboxrd became the default nearly everywhere.

Two things the guides get wrong. Several describe mboxcl2 as escaping From lines for safety. It does the opposite, relying entirely on Content-Length and escaping nothing. And mboxcl itself is described three different ways across otherwise reliable references, some saying it escapes reversibly, some irreversibly, some not at all. Anyone who needs to know for certain has to inspect the file rather than trust a description.

How to tell which MBOX variant you have

Open the file in any text editor. Plain text is the whole point of the format and two checks settle it.

  1. Search for Content-Length. Present on most messages means mboxcl or mboxcl2. Absent means mboxo or mboxrd.
  2. Search for a line starting >From. Present means escaping is happening, which points at mboxrd if there was no Content-Length.
  3. Neither found? You probably have mboxrd holding mail that never happened to need escaping. Treat it as mboxrd.

That third case comes up most and it is fine. A file only shows its escaping rule when some message forced the issue, so finding nothing is close to good news.

Which Mac applications write MBOX files

Three sources produce most of the MBOX files on Macs. They are not equally documented.

  • Thunderbird. Writes mboxrd. Alone among the three it says so plainly. It also stores mail this way rather than only exporting to it.
  • Apple Mail. The Export Mailbox command produces MBOX, though Apple has never published which variant. In practice the output is read by tools expecting mboxrd without complaint.
  • Google Takeout. Exports Gmail as MBOX. The result behaves as mboxrd.

Vendors document the format and not the variant. For nearly all purposes the answer is mboxrd anyway, which is presumably why the question rarely gets addressed.

What to do when an MBOX import fails

The variant is rarely the culprit. It is worth ruling out the ordinary explanations first.

A file that imports as an empty mailbox was nearly always not the file at all, because an Apple Mail export is not the single file it appears to be. That one catches almost everybody.

Messages missing or fragments of one appearing inside another is the variant problem showing itself. That is a parser applying the wrong escaping rule. Where the importing tool offers a variant setting, telling it what to expect is the fix.

How MBOX compares to the other mail formats

Anyone dealing with mail on a Mac meets four or five formats and MBOX sits in a particular place among them.

EML holds one message per file, which suits sending a few on. Apple Mail's own store uses EMLX, a variant of EML with extra framing. Outlook exports OLM and Windows Outlook uses PST, both of which are proprietary containers that need their own software or a converter. Maildir, the other Unix approach, gives each message its own file inside a directory rather than concatenating them.

MBOX is the only one of those that is both plain text and a whole mailbox in one piece. That combination is why it became the common currency for moving mail between applications that agree on nothing else.

Why the MBOX format survives

Four incompatible variants and no way to identify them sounds like a format nobody should use. It is still the one to ask for.

Read more: How to archive old Mac email to an external drive.

Everything is in plain text. A file opened in thirty years still shows its messages, whether or not a mail application exists to read it. RFC 4155 registered it as the application/mbox media type in 2005, making it a documented target rather than a convention. The practical incompatibility has largely dissolved too, since one variant won and the others survive mostly in archives.

The honest limitation is that MBOX carries messages and nothing else. Folder hierarchy, read states and account settings all live outside the file, so a migration needing those needs more than this. For keeping mail readable, which is the job most people actually have, it remains the least bad option by a wide margin.

Common questions

Can I open an MBOX file without an email client?

Yes. It is plain text, so the messages are readable in any editor. Attachments appear as long blocks of encoded characters rather than files, which is unreadable but confirms they are in there.

Is MBOX the same as EML?

No. An EML file holds one message. An MBOX file holds a whole mailbox in one file, with each message separated by a line starting From followed by a space. One is a message, the other is a container.

Which variant should I ask a converter for?

mboxrd, unless something specific says otherwise. It is what Thunderbird and Google Takeout produce and what most tools assume when nobody specifies.

Does the .mbox extension tell me the variant?

No. Neither does anything else in the filename. All four write files that look alike from outside. The only way to know is to open it and look at the message separators.

Do MBOX files store folder structure?

One file is one flat mailbox. Nesting is carried by how the files are arranged in directories, not by anything inside them, which is why a folder tree rarely survives an import. A Mac MBOX converter rebuilds the hierarchy on the way out.

Why do some MBOX files have Content-Length headers?

Because they were written in one of the two variants that use them to mark where each message ends, rather than scanning for separator lines. Both came from System V Unix and both are rare now.

Sources

Every date, version number and path above is taken from these pages rather than from memory.

  1. Mbox, on the four variants and their quoting rules Wikipedia
  2. RFC 4155, the application/mbox media type IETF
  3. Mbox file format reference, on which tools write which variant Just Solve the File Format Problem