Introduction
Apple Mail on the Mac stores each message
it downloads as a separate .emlx file inside the
~/Library/Mail folder. The file is an ordinary
EML message with a little extra data added by Mail: a
byte count in front and a list of Mail’s own details, such as read and flagged status,
after it. Spotlight indexes these files, which is how mail turns up in Mac searches.
Messages whose attachments Mail has stored separately are named
.partial.emlx. Apple does not publish the format, but its layout is simple
and well known.
Structure
0Length the message size in bytes, as decimal text, then a line feed1 line…Message the raw email, header fields then body, exactly that many bytesvaries…Property list an XML plist with Mail’s flags, dates and other detailsthe rest
To get a standard EML file, read the first line as a number and take that many bytes after it. The layout and flags page gives the property list keys and the flag bits.
Viewer
Drop an .emlx or .partial.emlx file on the viewer. The
Structure tree shows the three parts with their bytes: the byte count line, the
message and the property list. The message is read by the
email viewer, on the exact window the byte count
gives, so its header fields (addresses, dates, identifiers and encoded words decoded),
its MIME parts and its problems appear here as they would for an .eml file,
and every part and attachment opens as a file. The property list is read by the
property list reader: the Metadata tab lists
every key with its type and value, and the Flags tab decodes the flags
integer bit by bit, with the names from the emlx library (see the
layout and flags page). The message and
the property list can each be opened on their own.
Every problem is listed: a byte count that is not a number, is more than the file
holds or ends inside the message, a missing property list, text between the message
and the property list, a property list that is not a dictionary, a flags
value that is not an integer, and every problem of the message itself.
Not described
Apple has never published the format; the layout page follows the open-source
emlx reader and Jamie Zawinski's 2005 notes.
Known, not yet covered
- Viewer: the message is shown as far as the email viewer reads it: what the EML page lists there (signatures of S/MIME and PGP messages are described and never verified) is not covered here either.
- Viewer: the viewer reads the one file it is given. Mail keeps the
attachments of a
.partial.emlxmessage in separate files (as the introduction says); the viewer does not look for them.
Unknown
- Reference: the property list keys other than
color,conversation-id,date-last-viewedandflags: their names, value types and meaning are in no public document, only in files made by Mail. Viewer: every key is shown with its type and value and the words “not documented”; a key nameddate-something with a number in it is also shown read as seconds since 1970, which is a guess. - Reference: flag bits 31 and up (newer Mail versions use more); the source does not name them. Viewer: they are shown as “other bits”, in hexadecimal, with no name.
- Reference: why an attachment count of 63 appears in some files (the reader notes it and drops it). Viewer: the 63 is shown as it is, with that note.
- Viewer: the layout of a
.partial.emlxfile is the same, as far as is known; no real one was available to check (the test files are built by a script), so the viewer reads it exactly as it reads an.emlxfile.
Links
Software
- Apple Mail – the Mac’s built-in email program, which stores each message as an .emlx file (macOS)