GitHub - postalsys/synthetic-email-corpus: Synthetic email test corpus for MIME parsers and email software (CC-BY 4.0)

GitHub

6 min read Original article ↗

A public test corpus of synthetic email for MIME parsers, mail clients and email infrastructure. Every message is fictional. The structure of each message (MIME tree, charsets, transfer encodings, header shapes, encoding quirks) was taken from real-world mail, and all content, names, addresses, links, images and attachments were replaced with invented ones.

  • 11,637 messages (v1.0.2) from 2003 to 2026 era mail clients and services
  • Many languages (mostly English and Estonian, plus Russian, Latvian, Finnish, German, Chinese, Korean, Japanese and others) in their original charsets
  • Expected-parse JSON for every message, cross-checked against three parsers
  • A per-message quirk manifest so tests can pick messages by feature
  • Live DKIM, ARC, SPF and DMARC for the signed mail, plus an offline DNS fixture
  • A separate set of deliberately broken variants
  • Synthetic remote images served from img.sc.imapkit.com, also included offline

Layout

Path Contents
messages/ The corpus, one sc-NNNNNN.eml per message, CRLF line endings
oracle/ Expected parse per message (<id>.json)
mutations/ Deliberately broken variants, <id>.<mutation>.eml
assets/ Offline copies of every remote image the messages reference
manifest/corpus.jsonl One JSON line per message: features, quirks, language, category, thread, expected DKIM result, parser disagreements
manifest/mutations.jsonl One JSON line per mutated message and the mutation applied
manifest/coverage.json How many messages carry each structural feature
manifest/dns-fixture.json Every DNS record the signed messages need, for offline verification
keys/ Public DKIM keys, the fixture signing key, the test S/MIME CA and certificates, PGP public keys
tools/ Offline mock server, large-message generator, offline authentication check, messages pack reader
sample/ A small sample of messages and oracles (the full set is in each release archive)

The repository holds the manifests, keys, tools and a sample. Each version's full set of messages, oracles, assets and mutations is attached to its GitHub release as an archive.

Each release also has a messages pack, synthetic-email-corpus-<version>.messages.zst: only messages/, mutations/, manifest/corpus.jsonl and manifest/mutations.jsonl, in one zstd stream that is quicker to download and to load than the full archive. After decompressing, it holds the 8 bytes SCPACK01, a 4 byte little endian index length, the JSON index { "version", "files": [{ "name", "offset", "size", "mtime" }] }, and then the files back to back (offsets count from the start of the data). node tools/read-pack.mjs lists, prints or extracts the files (Node.js 22.15 or newer, which has zstd built in).

Finding messages by feature

# Every message with an encoded-word in koi8-r
grep '"ew:koi8-r/' manifest/corpus.jsonl

# Every message where at least one parser disagrees with the oracle
grep -v '"parserDisagreements":{}' manifest/corpus.jsonl

Feature tags in features describe the published bytes:

Prefix Meaning
ct: A content type present in the MIME tree
cs: A declared charset
cte: A transfer encoding (other:<value> for non-standard values)
ew: An RFC 2047 encoded word, as charset/B or charset/Q
ext: An attachment file extension
size: Size bucket
quirk: A deviation from the standards or from common practice (see below)

generationQuirks lists properties added on purpose: broken DKIM signatures (dkim-broken-body, dkim-broken-header), S/MIME and PGP material (smime-signed, pgp-signed, pgp-encrypted, smime-enveloped), signing with the fixture key (dkim-fixture-key) and remote images that fail on purpose (remote-image-fault:<kind>).

Common quirk: tags: noncanonical-qp, qp-long-lines, qp-invalid-escape, qp-lowercase-hex, noncanonical-b64, b64-bad-chars, 8bit-in-7bit, 8bit-without-charset, 8bit-header, charset-mismatch, unknown-charset, cte-unknown, format-flowed, preamble-text, epilogue-text, missing-close-boundary, implicit-content-type, no-mime-version, no-message-id, no-date, rfc2231-params, header-line-over-998, body-line-over-998, malformed-header-line, bare-cr, nul-byte.

The oracle

oracle/<id>.json has expected (subject, addresses, date, message IDs, threading headers, hashes of the text and HTML bodies, attachments with size and SHA-256, and every MIME part) and parserDisagreements, which lists the fields where mailparser, postal-mime or Python's email package read the message differently. Disagreements are not necessarily bugs; they mark the messages where implementations diverge.

Body hashes are SHA-256 of the decoded text with CRLF turned into LF, trailing spaces and tabs removed from each line and leading or trailing blank space trimmed.

Remote images, links and unsubscribe

Messages refer to hosts under sc.imapkit.com:

  • img.sc.imapkit.com/v1/<id>/<n>.<ext> serves synthetic images. Paths never change.
  • img.sc.imapkit.com/fault/<kind>/<n>.<ext> fails on purpose: 404, redirect (three hops), slow (8 seconds), wrong-type, corrupt, huge (20 MB).
  • l.sc.imapkit.com/... answers every link with a neutral page.
  • u.sc.imapkit.com/... implements RFC 8058 one-click unsubscribe: a POST with List-Unsubscribe=One-Click returns 200.

These hosts keep no logs. To test without the network, run node tools/mock-server.mjs and resolve the three hosts to 127.0.0.1.

Authentication

Signed messages are signed by about 40 fictional brand domains under sc.imapkit.com. Their DKIM, SPF and DMARC records are live in DNS, and each domain has a null MX, so nothing can be delivered to them. ARC sets are sealed by arc.sc.imapkit.com.

In manifest/corpus.jsonl, dkim.expected is pass or invalid. Deliberately broken signatures are invalid; verifiers differ in how they report them (fail or neutral).

The private keys for these live domains are not published; verifying a signature only needs the public key. For signing tests, use the fixture key in keys/fixture/, which covers every .example domain in manifest/dns-fixture.json.

npm install mailauth
node tools/verify-auth.mjs messages/sc-000123.eml

S/MIME material chains to keys/smime/ca.pem (a test CA, not trusted anywhere). PGP public keys are in keys/pgp/.

Large messages

Message size is capped near 1 MB. For performance tests, build larger variants:

node tools/make-large.mjs messages/sc-000123.eml 25 > large.eml

How the corpus was made

Messages were selected from a private mail archive to cover every distinct MIME structure, charset, encoding and quirk, three per structure group plus whole threads. A deterministic pipeline kept each message's structure and encoding style and replaced every identifier with a consistent fictional one. A language model then wrote new content for the text, in the original language. Attachments and images were generated from scratch. No original binary was copied.

Every message had to pass automated release checks before publication:

  • no token, address, domain, phone number, account number, full name or rare surname from any message in the source archive
  • no copied passages (word 5-gram overlap with its source)
  • an independent model check for carried-over details and real brand names
  • a render check that the message still displays like the original layout

Nothing in this corpus refers to real people or organizations. If you believe a message contains real personal data, open an issue and it will be removed in the next version.

Contribute a message

Found an email that breaks a parser or an IMAP client, or one with a structure this corpus lacks? Submit it at https://submit.sc.imapkit.com. An automatic check compares it with the corpus and runs mailparser, postal-mime and ImapKit on it; a person reviews every submission. Accepted messages are anonymized the same way as the rest of the corpus and ship in the next version. Only the rewritten copy is ever published, and your file is deleted afterwards.

Versions

Messages keep their IDs across versions. New versions add messages; a fixed message keeps its ID and gets a higher revision. See CHANGELOG.md.

License

The corpus is licensed under CC BY 4.0. Credit it as:

Synthetic Email Corpus by Postal Systems OÜ, CC BY 4.0, https://github.com/postalsys/synthetic-email-corpus

The tools in tools/ are under the MIT license.