Internet-Draft CESAF November 2026
Conjeevaram Balasubramanian Expires 27 May 2027 [Page]
Workgroup:
Network Working Group
Internet-Draft:
draft-balasubramanian-cesaf-00
Published:
Intended Status:
Standards Track
Expires:
Author:
V. Conjeevaram Balasubramanian

CESAF: The Canonical Email Storage and Archive Format

Abstract

Email is kept in many incompatible forms: mbox files in several variants, Maildir directories, proprietary personal-folder files and ad hoc exports. Most of them lose or alter information, and each can be read only by some tools. This document specifies CESAF, the Canonical Email Storage and Archive Format: a file-based format in which mail from any source is kept in one store, each message exactly as it was obtained, together with the metadata a reader needs to present it (its source, folders and flags, decoded header fields, MIME structure, character sets and internationalized addresses). Any client that implements this document can read a store written by any other.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 27 May 2027.

▲

Table of Contents

1. Introduction

A person's or an organization's mail history is rarely in one place. Older mail sits in personal-folder files written by one desktop client, other mail in the local folders of another client, more in mbox exports from a provider, and the rest on an IMAP server. Each of these forms can be opened only by some tools, and each loses something:

This document specifies CESAF, the Canonical Email Storage and Archive Format. A CESAF store is a directory tree of ordinary files. It holds mail from any number of sources. Each message is kept as the octets obtained from its source, never modified; everything derived from it, and everything known about where it came from, is recorded beside it in a JSON record. Folders, flags and keywords are kept in small index files. A reader that implements this document can list a store's sources and folders, page through them by date and open each message; any program that can display a message in Internet Message Format [RFC5322] can open an individual message file.

1.1. Goals

  1. Keep every message exactly as obtained, including malformed and internationalized messages.

  2. Keep mail from many sources in one store, with each message's source and folder path.

  3. Record what a reader needs to present a message without re-parsing it, and keep that record regenerable from the message.

  4. Allow a store to be read and written by independent implementations, on every common file system.

  5. Allow lossless export back to common formats.

1.2. Non-Goals

This document does not change mail transport, the Internet Message Format or MIME. It does not define an access or synchronization protocol; JMAP [RFC8620] [RFC8621] and IMAP [RFC9051] remain the protocols for that. It does not define encryption or tamper evidence for stores; those may be specified as additions (see Section 11). It does not require any implementation to repair or normalize messages.

2. Conventions and Terminology

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

This document uses the following terms:

Store:

A directory tree that conforms to this document.

Source:

One archive or account imported into a store, such as a personal-folder file, a client's local folders, an mbox file or an IMAP account.

Mailbox:

A folder of a source, holding references to messages.

Message object:

A file that holds one message in Internet Message Format.

Original:

A message object whose octets are those obtained from the source.

Reconstructed:

A message object generated from a source that does not hold the message's original octets.

Message record:

A JSON document that describes one message object.

Provenance:

The part of a message record that cannot be recomputed from the message object.

Analysis:

The part of a message record that is computed from the message object and can be regenerated.

Filing date:

The date, fixed when a message is first stored, that determines where its files are placed.

Message id:

The identifier of a message object, computed from its octets.

Message key:

The filing month and message id of a message, which together give the location of its files.

Reader:

An implementation that reads stores.

Writer:

An implementation that creates or changes stores.

Addition:

A document that extends this format, identified in a store's manifest.

Times in JSON documents are date-time values of [RFC3339] in UTC. JSON documents in this specification are I-JSON [RFC7493] texts [RFC8259]. Their structure is given in CDDL [RFC8610]. ABNF follows [RFC5234].

3. Overview

A store separates what never changes from what does:

<store>/
  cesaf.json                         store manifest
  sources/<source-id>.json           one per source
  mailboxes/<mailbox-id>/
    folder.json                      name, parent, source, special use
    members-<yyyy>.json              members filed in year <yyyy>
  messages/<yyyy>/<mm>/<fan>/
    <id>.eml                         message object
    <id>.json                        message record
    <id>.source/                     optional source material
  index/ids-<fan>.txt                message id index
Figure 1: Layout of a store

A writer importing a message obtains its octets from the source (or reconstructs them; see Section 5.2), computes its message id, checks the id index, determines its filing date, writes the message object and its record, and adds a member entry to the mailbox it came from.

4. Store Layout

4.1. The Store Manifest

The root of a store MUST contain a file named "cesaf.json". Its presence identifies the directory as a CESAF store.

store-manifest = {
  "cesaf": 1,                    ; version of this document
  "store-id": tstr,              ; a UUID {{RFC9562}}, lowercase
  "created": tstr,               ; date-time, UTC
  "algorithms": [+ tstr],        ; message id algorithms in use
  ? "additions": [* addition],
  ? "policy": { ? "invalid-input": input-policy },
  * tstr => any                  ; extension members
}
addition = { "id": tstr, "critical": bool, * tstr => any }
input-policy = "keep" / "quarantine" / "reject"
Figure 2: Store manifest

A reader MUST ignore members it does not recognize. The value of "policy.invalid-input" defaults to "keep".

4.2. Message Ids

The message id of a message object is the string "sha256-" followed by the SHA-256 digest of the object's octets, encoded in lowercase base32 without padding ([RFC4648], Section 6, using the lowercase alphabet). A message id is therefore 59 characters long and contains only the characters a-z, 2-7 and "-". Lowercase letters are used so that ids remain distinct on file systems that ignore case.

Further algorithms MAY be registered (see Section 15). A store lists the algorithms in use in its manifest; a writer MUST NOT store objects under an algorithm the manifest does not list.

4.3. Message Files and Folder Sizes

Many file systems limit, or slow down badly with, the number of entries in one directory; FAT32, still common on removable media, allows about 65,000. Message files are therefore spread first by filing month and then by the first two characters of the digest part of the message id (the "fan"):

messages/<yyyy>/<mm>/<fan>/<id>.eml
messages/<yyyy>/<mm>/<fan>/<id>.json

where "yyyy" and "mm" are the year and month of the filing date (Section 4.4). Each month holds at most 1,024 fan directories.

A message object MUST be stored in a file named after its message id with the extension ".eml", so that any viewer of Internet Message Format can open it. Its record MUST be stored beside it with the extension ".json".

4.4. The Filing Date

The filing date of a message is determined once, when the message is first written to the store, and MUST NOT change afterwards. A writer MUST take it from the first of the following that is present and valid:

  1. "received": the date-time of the topmost "Received" header field of the message object, that is, the time the last receiving system accepted the message;

  2. "delivery": the delivery time the source records for the message (for example the IMAP INTERNALDATE, the delivery time stored in a personal-folder file, the date on an mbox separator line, or the modification time of a Maildir file);

  3. "date": the "Date" header field of the message object;

  4. "import": the time of import.

A date-time is valid for this purpose if it can be parsed and is not more than one day later than the time of import. The filing date is expressed in UTC. The writer MUST record the filing date and the rule that produced it in the message's provenance (Section 6.1).

Rules 1 and 3 depend only on the message's octets, so independent writers importing the same message usually choose the same filing date.

4.5. Message Keys

A message is referenced from mailboxes by its message key, which is its filing month and message id, for example:

2015-03/sha256-mzxw6ytboi...

A reader derives the paths of a message's files from its key alone.

4.6. The Id Index

Because rules 2 and 4 of Section 4.4 depend on the source, the same message could be filed under different months by different imports. To keep one copy of each message, a store has an id index:

index/ids-<fan>.txt

Each line of an index file holds a message id, one space and the message key, terminated by LF. Before writing a message object, a writer MUST look up its id in the index; if the id is present, the writer MUST NOT write a second copy and MUST reference the existing key instead. The index can be rebuilt by scanning "messages/"; a reader MUST NOT treat the index as authoritative where it disagrees with the files present.

4.7. Path Rules

Every file and directory name in a store is generated by the writer from ids, UUIDs, digits and fixed names; no name is ever taken from message content or from a folder name. Names MUST consist only of the characters a-z, 0-9, "-", "." and "_", and MUST NOT be longer than 80 characters. These rules keep a store usable on every common file system and allow the store directory to be used unchanged as the payload of a BagIt bag [RFC8493].

A reader MUST ignore files and directories it does not recognize.

5. Message Objects

5.1. Originals

An original message object holds the octets of the message as obtained from its source. For a message obtained from a file, these are the file's octets after removing any container framing (see Section 9); for a message obtained over IMAP, they are the octets of BODY[]; for a message delivered by a local delivery agent, they are the octets as handed over, including any trace header fields added on delivery.

A writer MUST NOT modify the octets of a message object. In particular, it MUST NOT re-fold or re-encode header fields, regenerate MIME boundaries, convert character sets, transfer encodings or line endings, or convert domain names between U-labels and A-labels. Messages that are malformed are stored as they are, unless the store's policy says otherwise (Section 4.1).

These rules preserve the evidence of what was received and keep signatures over the message, such as DKIM signatures, verifiable.

5.2. Reconstructed Messages

Some sources do not hold the octets of the messages they contain. Personal-folder files [MS-PST], for example, hold message properties, bodies and attachments separately. A writer importing from such a source MUST store a reconstructed message object: a message in Internet Message Format generated from the source's data, so that every reader can present it.

A writer generating a reconstructed message:

  • SHOULD use the original header fields when the source has kept them (for personal-folder files, the transport message headers property);

  • MUST generate MIME boundaries as described in Section 8.1;

  • MUST use CRLF line endings;

  • MUST mark the record's "kind" as "reconstructed" and record the method and the implementation that performed it (Section 6.1).

A writer SHOULD also keep the source's own data for the message in the "<id>.source/" directory beside the message object, so that the reconstruction can be repeated or improved. The content of that directory is source-specific and is described for each source format in Section 9.

A reconstructed message object is never byte-identical to the message as originally received, because those octets no longer exist. Readers SHOULD indicate to users that a message is reconstructed.

6. Message Records

Each message object has a record, a JSON document stored beside it. A record has two parts: provenance, which cannot be recomputed and MUST NOT change once written, and analysis, which is computed from the message object and MAY be replaced by a writer that recomputes it.

message-record = {
  "id": tstr,                    ; message id
  "kind": "original" / "reconstructed",
  "size": uint,                  ; octets in the message object
  "provenance": provenance,
  ? "analysis": analysis,
}

provenance = {
  "filed": tstr,                 ; filing date, date-time in UTC
  "filed-by": filing-rule,
  "obtained": [+ obtained],      ; one entry per import that found it
  ? "reconstruction": { "method": tstr, "tool": tstr },
  ? "verification": [* verification],
}

filing-rule = "received" / "delivery" / "date" / "import"

obtained = {
  "source": tstr,                ; source id
  "at": tstr,                    ; time of import
  "tool": tstr,                  ; implementation name and version
  "location": { * tstr => any }, ; per source format
}

verification = {
  "method": tstr,                ; for example "dkim"
  "result": tstr,
  "at": tstr,
  ? "key-record": tstr,          ; the DNS record used, as text
}

analysis = {
  "analyser": tstr,
  "unicode": tstr,               ; Unicode version used
  "framing": framing,
  "headers": [* header],
  ? "addresses": [* address],
  ? "mime": mime-part,
  ? "findings": [* tstr],
}

framing = {
  "eol": eol-discipline,
  "eight-bit": bool,
  "nul": bool,
  "longest-line": uint,
}

eol-discipline = "crlf" / "lf" / "cr" / "mixed"

header = {
  "name": tstr,
  "range": [uint, uint],         ; first octet and length
  ? "decoded": tstr,             ; RFC 2047 and RFC 2231 decoded, NFC
  ? "error": tstr,
}

address = {
  "field": tstr,
  "original": tstr,
  ? "display-name": tstr,
  "local-part": tstr,
  "domain-u-label": tstr,
  "domain-a-label": tstr,
  "smtputf8": bool,
  ? "confusable": bool,
}

mime-part = {
  "path": tstr,                  ; "1", "1.2", ...
  "range": [uint, uint],
  "type": tstr,
  ? "parameters": { * tstr => tstr },
  ? "boundary": { "declared": tstr, "found": bool },
  ? "transfer-encoding": tstr,
  ? "charset": { ? "declared": tstr, ? "observed": tstr },
  ? "parts": [* mime-part],
  ? "findings": [* tstr],
}
Figure 3: Message record

6.1. Provenance

"filed" and "filed-by" record the filing date and the rule of Section 4.4 that produced it. "obtained" lists every import in which the message was found; a writer that finds an existing message during a later import MUST append an entry rather than replace one. The "location" member identifies the message in its source; its members for each source format are given in Section 9.

A writer that verifies signatures in a message MAY record the result in "verification". Because the keys used to verify DKIM signatures change over time, a writer that records a DKIM result SHOULD also record the DNS key record it used.

6.2. Analysis

Analysis records facts computed from the message object: its line-ending discipline, the position and decoded value of each header field, the internationalized forms of each address, and the MIME structure with the declared and observed character set of each part. The rules for computing these values are given in Section 8. Byte ranges are offsets into the message object.

A writer MAY recompute and replace analysis at any time, and MUST then update "analyser" and "unicode". A reader MUST NOT rely on analysis being present, and MUST be able to present a message from the message object alone.

An addition that hashes or signs a record is expected to apply the JSON Canonicalization Scheme [RFC8785] first, so that independent implementations hash the same octets.

7. Mailboxes and Flags

7.1. Sources

Each source has a file "sources/<source-id>.json", where the source id is a lowercase UUID [RFC9562].

source = {
  "id": tstr,
  "format": tstr,                ; from the source format registry
  "name": tstr,                  ; for display, chosen by the user
  ? "location": tstr,            ; for example the original file name
  "imported": [+ { "at": tstr, "tool": tstr, "count": uint }],
}
Figure 4: Source

7.2. Folders

Each mailbox is a directory "mailboxes/<mailbox-id>/", where the mailbox id is a lowercase UUID. Its "folder.json" describes it:

folder = {
  "id": tstr,
  "name": tstr,                  ; UTF-8, NFC
  ? "name-raw": tstr,            ; as found, if different
  ? "parent": tstr,              ; mailbox id
  "source": tstr,                ; source id
  ? "special-use": tstr,         ; special-use attribute
}
Figure 5: Folder

The "special-use" member holds a special-use attribute of [RFC6154], such as "\Sent" or "\Trash", when the source identifies the folder as one. Folder names never appear in paths (Section 4.7), so a name can contain any character.

7.3. Members

The members of a mailbox are listed in one file per filing year, "members-<yyyy>.json", so that large mailboxes stay manageable and can be browsed by date.

members = {
  "year": uint,
  "members": [* member],         ; sorted by filing date
}
member = {
  "key": tstr,                   ; message key
  ? "flags": [* tstr],           ; IMAP system flags
  ? "keywords": [* tstr],
  "added": tstr,
}
Figure 6: Members

Flag names are those of IMAP [RFC9051]. Keywords hold tags and labels. The same message MAY be a member of several mailboxes, with different flags in each; this is how labels from sources that allow a message in several folders are represented.

A member with the "\Deleted" flag remains in the store. Readers SHOULD hide such members by default, as mail clients do. A writer MAY purge them; a purge removes the member entries and, when no mailbox refers to a message any longer, MAY remove its files and its id index line.

A writer that changes a members file MUST write the new content to a temporary file in the same directory and then rename it over the old file, so that a reader never sees a partial file.

8. Internationalization

Internet mail was designed for 7-bit ASCII. Non-ASCII text, domain names and addresses are carried by several mechanisms, and real messages often use them incorrectly. An archive format must keep what was received while still letting readers present it. This section gives the rules; Section 8.6 summarizes them.

8.1. MIME Boundaries

The boundary parameter of a multipart body is defined in [RFC2046]:

boundary      = 0*69bchars bcharsnospace
bchars        = bcharsnospace / " "
bcharsnospace = DIGIT / ALPHA / "'" / "(" / ")" /
                "+" / "_" / "," / "-" / "." /
                "/" / ":" / "=" / "?"
Figure 7: Boundary syntax, from RFC 2046

A delimiter line is "--" followed by the boundary; the closing delimiter adds a further "--". The CRLF that precedes a delimiter belongs to the delimiter, so a body part can end without a line break. Receivers tolerate trailing white space after a delimiter.

Real messages contain boundaries that also occur inside a part, the same boundary reused at two nesting levels, missing closing delimiters, incorrectly quoted parameters, and delimiter lines with LF instead of CRLF. A writer MUST store such messages unchanged. Its analysis SHOULD record, for each multipart, the boundary as declared, whether it was found, and any of these defects as findings.

A writer that generates a message (a reconstructed message, or an export that must rewrite one) MUST generate each boundary from at least 128 bits of randomness, MUST use a different boundary at each nesting level, and MUST apply the rule that the preceding CRLF belongs to the delimiter.

8.2. Internationalized Domain Names

Domain names in addresses may appear as A-labels (the ASCII form beginning "xn--" [RFC3492]) or as U-labels (Unicode) [RFC5890].

A writer MUST NOT convert domain names between the two forms in a message object. For each address, analysis records both forms: "domain-a-label" and "domain-u-label", computed according to IDNA2008 [RFC5891]. A domain that is not valid under IDNA2008 is recorded as found, with a finding. The mapping of [UTS46] MAY be applied when looking up or displaying a name entered by a user, but MUST NOT be used to compute the values stored in analysis.

8.3. Internationalized Addresses

With the SMTPUTF8 extension [RFC6531] and internationalized header fields [RFC6532], the local part and the domain of an address may be UTF-8 [RFC6530]. For each address, analysis records the original form exactly as it appears in the header field, the decoded display name, the local part, both domain forms, and whether the address requires SMTPUTF8 ("smtputf8"). An address whose local part contains non-ASCII characters requires it; one whose only non-ASCII characters are in the domain does not, because the domain can be expressed as A-labels.

Different characters can look identical. A writer SHOULD mark an address as "confusable" when its display name or its U-label domain mixes scripts or contains characters identified as confusable by [UTS39].

The address form recorded in analysis is identified by one of:

address-form = "original" / "u-label" / "a-label"
Figure 8: Address forms

8.4. Character Sets and Encodings

A body part declares its character set in the "charset" parameter and may use a transfer encoding [RFC2045]; header fields may contain encoded words [RFC2047] [RFC2231] or, with [RFC6532], raw UTF-8.

For each text part, analysis records the declared character set and, where it differs, the observed one. A writer MUST NOT infer the character set of a body from its header fields. Common defects to record as findings include: a declared character set that does not match the octets (UTF-8 octets declared as ISO-8859-1 or windows-1252); text encoded twice; a missing or wrong charset parameter; raw 8-bit header fields without SMTPUTF8; overlong UTF-8 sequences and unpaired surrogates; 8-bit data without a transfer encoding; and lines folded inside a multi-octet character.

UTF-16 and UTF-32 are rare in mail and need a byte order mark or an explicit label, and in practice base64. A writer MUST store such parts unchanged and SHOULD record a finding; readers MAY offer conversion to UTF-8 for display.

Decoded values in analysis (header values, display names, folder names) are UTF-8 in Normalization Form C [UAX15]. Folder names obtained from sources in other encodings, such as the modified UTF-7 of IMAP mailbox names or a legacy code page, are converted to UTF-8 NFC for the "name" member of "folder.json", and the original is kept in "name-raw".

Invalid sequences are kept in the message object. A writer MUST NOT reject or quarantine a message for invalid encoding unless the store's policy requires it (Section 4.1).

8.5. Line Endings

Messages in Internet Message Format use CRLF, but files written by many tools use LF, and some mix the two. A writer MUST keep line endings as obtained and MUST record the discipline observed:

eol-discipline = "crlf" / "lf" / "cr" / "mixed"
Figure 9: Line-ending disciplines

Line endings are converted only when a message is exported to a destination that requires CRLF (for example, submission over SMTP); such an export produces a copy and never changes the stored object.

8.6. Summary

Table 1: Internationalization rules
Issue Storage rule Analysis
MIME boundaries Keep exactly as obtained Record the declared boundary and defects; generate new boundaries only for new messages, from 128 bits of randomness
IDNA (Punycode) domains Keep the form used Record both U-label and A-label (IDNA2008)
SMTPUTF8 addresses Keep the form used Record whether SMTPUTF8 is required; mark confusables
UTF-8 bodies and header fields Keep the octets Record declared and observed character sets; decode to NFC
UTF-16 / UTF-32 Keep the octets Record a finding; convert only for display
Line endings Keep the octets Record the discipline; convert only in exports that require CRLF

8.7. Other Syntax

The filing rule and the message key (Section 4.4, Section 4.5) have the following syntax:

filing-rule  = "received" / "delivery" / "date" / "import"
message-key  = filing-month "/" message-id
filing-month = 4DIGIT "-" 2DIGIT
message-id   = "sha256-" 52b32char
b32char      = %x61-7A / %x32-37
Figure 10: Filing rules and message keys

9. Import and Export

An import creates a source (Section 7.1), creates a mailbox for each of the source's folders, and stores each message as described in Section 5. This section gives the rules for each source format and the members of "location" (Section 6.1) that identify a message in it. Source format names are registered in Section 15.

9.1. Single Messages

A file holding one message in Internet Message Format ("eml") is stored as an original with the file's octets. Location: "file", the file's name.

9.2. mbox

An mbox file [RFC4155] holds messages separated by lines beginning with "From ". Four variants are common:

  • mboxo: lines in a message beginning with "From " are escaped as ">From "; existing ">From " lines are not escaped further, so the escaping cannot be undone with certainty.

  • mboxrd: every line matching ">*From " gains one ">", so the escaping can be undone exactly.

  • mboxcl and mboxcl2: a Content-Length header field gives the length of each message; mboxcl escapes as mboxo does, mboxcl2 does not escape.

A writer MUST remove the separator line and MUST record it in location ("separator"). It MUST undo the escaping only when the variant is known and the escaping is reversible (mboxrd, and mboxcl2, which has none). Otherwise it MUST store the message with the escaping in place and record "quoting": "retained", so that no message is changed on a guess. Location: "file", "offset" (of the separator line), "variant", "separator", and "quoting" when retained.

9.3. Thunderbird Local Folders

The local folders of Thunderbird and related clients store each folder as an mbox file, with subfolders in a directory named after the folder with the suffix ".sbd". Index files with the suffix ".msf" are caches and MUST be ignored: everything needed is in the mbox files.

These clients add header fields to stored messages: "X-Mozilla-Status" and "X-Mozilla-Status2" (hexadecimal flag words) and "X-Mozilla-Keys" (tags). They are part of the stored octets and MUST be kept. A writer SHOULD decode them into the member entry: the read, replied, flagged and deleted bits to "\Seen", "\Answered", "\Flagged" and "\Deleted", and the tags to keywords.

These clients mark deleted messages without removing them until the folder is compacted. A writer MUST import such messages with the "\Deleted" flag; it MUST NOT drop them, so that nothing in the source is lost. Location: as for mbox, plus "folder-path", the path of the folder within the profile.

9.4. Maildir

Each Maildir [MAILDIR] message file is stored as an original. The flag letters in the file name ("S", "R", "F", "T", "D") map to "\Seen", "\Answered", "\Flagged", "\Deleted" and "\Draft". Folders follow the naming convention of the Maildir in use. Location: "file" (the name, including the info part).

9.5. Personal-Folder Files

Personal-folder files [MS-PST] hold a tree of folders whose messages are sets of properties rather than octets. A writer MUST store each message as a reconstructed message (Section 5.2):

  • When the transport message headers property is present, the writer SHOULD use those header fields, unchanged, as the header of the reconstructed message, adjusting only the MIME header fields needed for the reconstructed body.

  • Otherwise it MUST generate header fields from the sender, recipient, subject, date and message-id properties.

  • It MUST include the plain-text and HTML bodies present, as a multipart/alternative, and every attachment, each with its file name and media type. Embedded messages become message/rfc822 parts.

The writer SHOULD store in "<id>.source/" a file "properties.json" holding the message's properties, and the attachments as extracted, so that a later implementation can reconstruct the message again. Folder names are converted as described in Section 8.4. Location: "file", "folder-path" and "entry-id" (hexadecimal).

Because a reconstructed message's id is computed from its octets, a later reconstruction by a different implementation will usually produce a different id. A writer re-importing a personal-folder file SHOULD match messages by "entry-id" before creating new ones (see Appendix A).

9.6. IMAP

A writer importing over IMAP [RFC9051] stores BODY[] as an original and the message's flags and keywords in the member entry. Location: "server", "mailbox", "uidvalidity", "uid", "internaldate" and, where available, "modseq".

9.7. Export

A writer exporting a store or a mailbox MUST support export of each message object unchanged as a ".eml" file. It SHOULD support export to mbox (as mboxrd, or as the original variant with the original separator lines when exporting messages imported from mbox), to Maildir with flags in file names, and to a plain directory tree named after folder names for users without a CESAF reader. An export MUST NOT change the store.

10. Conformance

This document defines two conformance classes.

Reader:

An implementation that opens a store, lists its sources and mailboxes, pages through members by year, presents messages with their flags, and exports. A reader MUST implement Section 4, Section 5, Section 7 and Section 9.7, and MUST NOT change a store.

Writer:

A reader that also imports messages, changes flags and keywords, and moves messages between mailboxes. A writer MUST implement every requirement of this document that applies to the source formats it supports, and MUST state which source formats those are.

Each requirement of this document is covered by at least one test vector (Appendix B). An implementation SHOULD publish the results of running the test vectors.

11. Extensions

This document can be extended by additions: documents that define further files, members or rules. Each addition has an identifier registered with IANA (Section 15). A store that uses an addition lists it in the "additions" member of its manifest, with a "critical" flag.

A reader that does not implement an addition listed as critical MUST NOT write to the store, and SHOULD tell the user that some content may not be presented correctly. A reader MAY ignore an addition that is not critical. An addition MUST NOT change the meaning of the files and members defined by this document.

Additions under consideration include a packaging of stores as BagIt bags [RFC8493] for transfer and fixity, and storage protections such as encryption and tamper evidence. None is specified by this document.

12. Implementation Status

Note to the RFC Editor: please remove this section before publication.

This section records the status of known implementations of the format defined by this document at the time of posting, as described in [RFC7942]. The description of implementations in this section is intended to assist the IETF in its decision processes in progressing drafts to RFCs. Please note that the listing of any individual implementation here does not imply endorsement by the IETF. Furthermore, no effort has been spent to verify the information presented here that was supplied by IETF contributors.

At the time of writing, no implementation exists. A reference implementation, a library and command-line tool that import personal-folder files, Thunderbird local folders, mbox, Maildir and single messages into a store, is being developed together with the test vectors of Appendix B.

13. Security Considerations

Messages are created by their senders, who may be hostile. An implementation MUST treat every message object, source file and record as untrusted input: parsers of MIME structure, encoded words, character sets and personal-folder files are frequent sources of memory-safety and resource-exhaustion defects, and SHOULD be written in memory-safe languages or isolated, and tested with malformed input. Byte ranges and lengths in records MUST be checked against the size of the message object before use.

No file or directory name in a store is taken from message content or from folder names (Section 4.7), which prevents path traversal through crafted names. A reader MUST NOT follow symbolic links found inside a store.

Opening a message from a store carries the same risks as opening it in any mail client: active content, remote images and executable attachments. Readers SHOULD apply the protections they apply to mail in general.

This document provides neither confidentiality nor tamper evidence: a store is as protected as the file system it is on. Anyone who can write to the store can change flags, mailboxes and analysis, and can replace message objects; a change to a message object is detectable by recomputing its message id, but a coordinated change to the object, its record and the indexes is not. Users who need protection SHOULD keep stores on encrypted storage with appropriate access control until an addition (Section 11) defines more.

Displaying confusable addresses (Section 8.3) as if they were the addresses they imitate can mislead users; readers SHOULD use the "confusable" mark to warn them.

Keeping messages unchanged preserves their signatures; it also preserves any malicious content, which is a deliberate property of an archive.

14. Privacy Considerations

A store holds personal data about its owner and about everyone who corresponded with them; the considerations of [RFC6973] apply to any system that hosts one. The format adds little to what the messages themselves reveal, with these exceptions:

Deleting a message completely requires removing its member entries, its message object and record, its "<id>.source/" directory if present, and its id index line; a purge (Section 7.3) does this. Copies of the store, such as backups, are not affected by a purge.

Implementations SHOULD NOT copy message content or addresses into logs or diagnostics.

15. IANA Considerations

This document asks IANA to create a "CESAF" registry group with the following registries. All use the Specification Required policy ([RFC8126] Section 4.6).

15.1. CESAF Additions

Each entry has an identifier (lowercase letters, digits and "-"), a description and a reference. The registry is initially empty.

15.2. CESAF Message Id Algorithms

Each entry has a name, as it appears before the "-" in a message id, a description of how the digest is computed and encoded, and a reference. Initial entry:

Table 2: Initial message id algorithms
Name Description Reference
sha256 SHA-256 of the message object, lowercase base32 without padding Section 4.2

15.3. CESAF Source Formats

Each entry has a name, a description and a reference giving its import rules and "location" members. Initial entries:

Table 3: Initial source formats
Name Description Reference
eml One message per file Section 9.1
mbox mbox in any variant Section 9.2
thunderbird Thunderbird local folders Section 9.3
maildir Maildir Section 9.4
pst Personal-folder file Section 9.5
imap IMAP account Section 9.6

15.4. Media Type

IANA is asked to register the media type "application/cesaf+json" for store manifests ("cesaf.json"), with the following template:

Type name:

application

Subtype name:

cesaf+json

Required parameters:

N/A

Optional parameters:

N/A

Encoding considerations:

binary; as for application/json

Security considerations:

See Section 13.

Interoperability considerations:

N/A

Published specification:

This document

Applications that use this media type:

Email archiving and email client software.

Fragment identifier considerations:

N/A

Additional information:

File extension: none (the file is always named "cesaf.json")

Person and email address to contact for further information:

The author of this document.

Intended usage:

COMMON

Restrictions on usage:

None

Author:

See the Author's Address section of this document.

Change controller:

IETF

16. References

16.1. Normative References

[RFC2045]
Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, DOI 10.17487/RFC2045, , <https://www.rfc-editor.org/rfc/rfc2045>.
[RFC2046]
Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, , <https://www.rfc-editor.org/rfc/rfc2046>.
[RFC2047]
Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text", RFC 2047, DOI 10.17487/RFC2047, , <https://www.rfc-editor.org/rfc/rfc2047>.
[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/rfc/rfc2119>.
[RFC2231]
Freed, N. and K. Moore, "MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations", RFC 2231, DOI 10.17487/RFC2231, , <https://www.rfc-editor.org/rfc/rfc2231>.
[RFC3492]
Costello, A., "Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)", RFC 3492, DOI 10.17487/RFC3492, , <https://www.rfc-editor.org/rfc/rfc3492>.
[RFC4648]
Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, DOI 10.17487/RFC4648, , <https://www.rfc-editor.org/rfc/rfc4648>.
[RFC5234]
Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/RFC5234, , <https://www.rfc-editor.org/rfc/rfc5234>.
[RFC5322]
Resnick, P., Ed., "Internet Message Format", RFC 5322, DOI 10.17487/RFC5322, , <https://www.rfc-editor.org/rfc/rfc5322>.
[RFC5890]
Klensin, J., "Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework", RFC 5890, DOI 10.17487/RFC5890, , <https://www.rfc-editor.org/rfc/rfc5890>.
[RFC5891]
Klensin, J., "Internationalized Domain Names in Applications (IDNA): Protocol", RFC 5891, DOI 10.17487/RFC5891, , <https://www.rfc-editor.org/rfc/rfc5891>.
[RFC6154]
Leiba, B. and J. Nicolson, "IMAP LIST Extension for Special-Use Mailboxes", RFC 6154, DOI 10.17487/RFC6154, , <https://www.rfc-editor.org/rfc/rfc6154>.
[RFC6531]
Yao, J. and W. Mao, "SMTP Extension for Internationalized Email", RFC 6531, DOI 10.17487/RFC6531, , <https://www.rfc-editor.org/rfc/rfc6531>.
[RFC6532]
Yang, A., Steele, S., and N. Freed, "Internationalized Email Headers", RFC 6532, DOI 10.17487/RFC6532, , <https://www.rfc-editor.org/rfc/rfc6532>.
[RFC7493]
Bray, T., Ed., "The I-JSON Message Format", RFC 7493, DOI 10.17487/RFC7493, , <https://www.rfc-editor.org/rfc/rfc7493>.
[RFC8126]
Cotton, M., Leiba, B., and T. Narten, "Guidelines for Writing an IANA Considerations Section in RFCs", BCP 26, RFC 8126, DOI 10.17487/RFC8126, , <https://www.rfc-editor.org/rfc/rfc8126>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <https://www.rfc-editor.org/rfc/rfc8174>.
[RFC8259]
Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/rfc/rfc8259>.
[RFC8610]
Birkholz, H., Vigano, C., and C. Bormann, "Concise Data Definition Language (CDDL): A Notational Convention to Express Concise Binary Object Representation (CBOR) and JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, , <https://www.rfc-editor.org/rfc/rfc8610>.
[RFC9051]
Melnikov, A., Ed. and B. Leiba, Ed., "Internet Message Access Protocol (IMAP) - Version 4rev2", RFC 9051, DOI 10.17487/RFC9051, , <https://www.rfc-editor.org/rfc/rfc9051>.
[RFC9562]
Davis, K., Peabody, B., and P. Leach, "Universally Unique IDentifiers (UUIDs)", RFC 9562, DOI 10.17487/RFC9562, , <https://www.rfc-editor.org/rfc/rfc9562>.
[UAX15]
The Unicode Consortium, "Unicode Normalization Forms", Unicode Standard Annex #15, n.d., <https://www.unicode.org/reports/tr15/>.

16.2. Informative References

[EAXS]
Collaborative Electronic Records Project, "Email Account XML Schema (EAXS)", n.d., <https://www.archives.ncdcr.gov/>.
[MAILDIR]
Bernstein, D. J., "Using maildir format", n.d., <https://cr.yp.to/proto/maildir.html>.
[MS-PST]
Microsoft Corporation, "[MS-PST]: Outlook Personal Folders (.pst) File Format", n.d., <https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-pst/>.
[OCFL]
OCFL Editorial Group, "Oxford Common File Layout Specification 1.1", n.d., <https://ocfl.io/1.1/spec/>.
[RFC3339]
Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, , <https://www.rfc-editor.org/rfc/rfc3339>.
[RFC4155]
Hall, E., "The application/mbox Media Type", RFC 4155, DOI 10.17487/RFC4155, , <https://www.rfc-editor.org/rfc/rfc4155>.
[RFC6530]
Klensin, J. and Y. Ko, "Overview and Framework for Internationalized Email", RFC 6530, DOI 10.17487/RFC6530, , <https://www.rfc-editor.org/rfc/rfc6530>.
[RFC6973]
Cooper, A., Tschofenig, H., Aboba, B., Peterson, J., Morris, J., Hansen, M., and R. Smith, "Privacy Considerations for Internet Protocols", RFC 6973, DOI 10.17487/RFC6973, , <https://www.rfc-editor.org/rfc/rfc6973>.
[RFC7942]
Sheffer, Y. and A. Farrel, "Improving Awareness of Running Code: The Implementation Status Section", BCP 205, RFC 7942, DOI 10.17487/RFC7942, , <https://www.rfc-editor.org/rfc/rfc7942>.
[RFC8493]
Kunze, J., Littman, J., Madden, E., Scancella, J., and C. Adams, "The BagIt File Packaging Format (V1.0)", RFC 8493, DOI 10.17487/RFC8493, , <https://www.rfc-editor.org/rfc/rfc8493>.
[RFC8620]
Jenkins, N. and C. Newman, "The JSON Meta Application Protocol (JMAP)", RFC 8620, DOI 10.17487/RFC8620, , <https://www.rfc-editor.org/rfc/rfc8620>.
[RFC8621]
Jenkins, N. and C. Newman, "The JSON Meta Application Protocol (JMAP) for Mail", RFC 8621, DOI 10.17487/RFC8621, , <https://www.rfc-editor.org/rfc/rfc8621>.
[RFC8785]
Rundgren, A., Jordan, B., and S. Erdtman, "JSON Canonicalization Scheme (JCS)", RFC 8785, DOI 10.17487/RFC8785, , <https://www.rfc-editor.org/rfc/rfc8785>.
[UTS39]
The Unicode Consortium, "Unicode Security Mechanisms", Unicode Technical Standard #39, n.d., <https://www.unicode.org/reports/tr39/>.
[UTS46]
The Unicode Consortium, "Unicode IDNA Compatibility Processing", Unicode Technical Standard #46, n.d., <https://www.unicode.org/reports/tr46/>.

Appendix A. Open Questions

This appendix lists questions the author would like the community's view on. It will be removed before publication.

  1. Q-1: Is SHA-256 alone sufficient for message ids, or should the format require a second algorithm from the start? (see Section 4.2)

  2. Q-2: Which heuristics should be specified for detecting mbox variants, and how should their limits be stated? (see Section 9.2)

  3. Q-3: Is membership of one message in several mailboxes sufficient to represent labels from all common sources? (see Section 7.3)

  4. Q-4: Should a store as a whole have a media type or a packaged form, in addition to the manifest's media type? (see Section 15)

  5. Q-5: Which related work should be cited and compared in more depth, for example EAXS, PREMIS and OCFL? (see Section 1.3)

  6. Q-6: Is an Operational Considerations section needed, for example on very large stores and network file systems? (see Section 4)

  7. Q-7: Copies of the same message with different octets from different sources are kept separately. Should the format record that two copies are likely the same message, and should a user be able to merge them? (see Section 4.6)

  8. Q-8: Should the id of a reconstructed message be derived from its source entry rather than from its octets, so that a later reconstruction keeps the same id? (see Section 5.2)

  9. Q-9: Should the format define rules for several writers using one store at the same time, such as lock files, or require a single writer? (see Section 7.3)

  10. Q-10: Filing months are in UTC, so a message received late in the evening in a time zone east or west of UTC may be filed under the neighbouring month. Is this acceptable? (see Section 4.4)

  11. Q-11: Should the id index be a plain text file per fan, as now, or part of the manifest, and must writers keep it current? (see Section 4.6)

Appendix B. Test Vectors

Test vectors will be published with the reference implementation. Each is a source archive or message together with the store an implementation is expected to produce, and the requirements it covers. The planned catalogue:

Table 4: Planned test vectors
Id Covers
tv-layout-01 manifest, ids, fan-out, filing dates by each rule
tv-dedup-01 the same message from two sources stored once
tv-mime-01 boundary inside a part, reused boundary, missing close delimiter
tv-idna-01 U-label and A-label domains, invalid IDNA2008 labels
tv-eai-01 UTF-8 local parts, SMTPUTF8 detection, confusables
tv-charset-01 mislabelled charsets, double encoding, UTF-16 bodies
tv-eol-01 LF-only, CR-only and mixed line endings
tv-mbox-01 each mbox variant, including mboxo retained quoting
tv-thunderbird-01 folder tree, status headers, deleted messages kept
tv-maildir-01 flags in file names
tv-pst-01 reconstruction with and without transport headers, attachments, embedded messages
tv-export-01 round trip of originals to .eml, mbox and Maildir

Acknowledgments

The rules for MIME boundaries, internationalized addresses and character sets build on long discussion in the email community about what archives lose and why.

Author's Address

Venkatraman Conjeevaram Balasubramanian