Introduction
An EML file is one email message saved exactly as it travels between mail servers: the header lines, then the body, with any attachments encoded as text. The layout is the Internet Message Format, now RFC 5322, which goes back to RFC 822 from 1982, together with the MIME standards that added attachments, other character sets and messages in several parts. Mail programs save and open single messages in this form, and many can import a folder of them. A mailbox of many such messages in one file is an mbox.
Structure
The file is text with lines ending in a carriage return and line feed. It starts with
header fields, one per line in the form Name: value, such as
From, To, Subject, Date and
Message-ID. A long field continues on lines that start with a space or a
tab. Text outside plain ASCII is written as an encoded word, such as
=?UTF-8?B?…?=.
An empty line ends the header, and the body follows. MIME fields say how to read it:
Content-Type gives its type and character set, and
Content-Transfer-Encoding says whether it is plain, quoted-printable or
base64. A multipart body is split into parts by a boundary line named in
the header; each part has its own header fields and body, and parts can be nested. This
is how a message carries a plain text version, an HTML version and attachments
together. The header fields and
MIME pages give the details.
0Header fields From, To, Subject, Date, MIME fieldslines…Empty line2 bytes…Body text, or MIME parts between boundary linesthe rest…Part its own header fields, an empty line, its contentrepeated
Not described
The header-field and MIME pages follow RFCs 5322, 2045–2049, 2183, 2231, 1864 and the others they name, plus RFC 6522, 3464 and 8098 (reports), 6376 (DKIM), 8617 (ARC), 8601 (Authentication-Results), 7208 section 9.1 (Received-SPF) and 2369 (list fields). The viewer also reads, from the sources it was built on, RFC 1847, 3156 and 8551 (signed and encrypted structure), MS-OXTNEF (TNEF, Microsoft’s public specification), the yEnc 1.3 draft and the POSIX uuencode(1) page. What they leave out:
Known, not yet covered
- Viewer: the header fields are decoded by kind (addresses, dates,
identifiers, parameters with RFC 2231, RFC 2047 encoded words), the MIME tree shows every
part with its boundaries, and every part opens decoded by its Content-Transfer-Encoding
and charset; a message/rfc822 part opens as a message of its own. The file is read in
windows (the headers of an entity, its boundary lines, and a body as it is counted or
opened), so a message of any size opens. Also read: message/delivery-status and
message/disposition-notification are split into their blocks of header fields, with the
required fields and the values of Action, Status, Disposition and the dates checked (RFC 3464,
RFC 8098); uuencode (
begin…end, and thebegin-base64form) and yEnc files written into a text body are found and open as entries, a yEnc file checked against its size and CRC-32; a winmail.dat (TNEF) part opens as an entry and a small reader lists its attributes and attachments (MS-OXTNEF section 2.1.3); S/MIME and PGP/MIME structure (multipart/signed, application/pkcs7-mime, multipart/encrypted, application/pgp-encrypted) is described, with the signature parts as entries; the tag list of a DKIM-Signature field is read (RFC 6376 section 3.2). Not covered: signatures are never verified and nothing is decrypted (that needs certificates, keys and passphrases that are not in the message), a DKIM signature is not checked (that needs the signer’s public key from DNS and the canonicalised message), ARC (RFC 8617) signatures, the MAPI properties inside a TNEF attribute (they are counted, not decoded), the CMS data inside an S/MIME part, uuencode or yEnc inside a quoted-printable or base64 text part (only a text body sent as 7bit, 8bit or binary is scanned), multi-part yEnc files joined across several messages, an HTML body drawn as a page (it is shown as source), the obsolete address routes, and a structured reading of the Received field. A part opens as an entry up to the 256 MiB limit the entry list sets, and says so when it is cut.
Unknown
- Reference: the status codes added after RFC 3463 (IANA's enhanced status codes registry), and the other header fields in IANA's message header field registries beyond the ones listed above; both lists are open-ended and neither has a single specification.
Links
Software
- Mozilla Thunderbird – free email program that opens and saves EML files (Windows, macOS, Linux)
- Microsoft Outlook – Microsoft’s email program, which opens EML files (Windows, macOS)
- Apple Mail – the Mac’s built-in email program (macOS)
- Notepad++ – text editor, like any other, that shows the raw message (Windows)