Synthetic Email Corpus
The Synthetic Email Corpus is a public set of 11,637 fictional messages whose structure was taken from real mail: MIME trees, charsets, transfer encodings, header shapes and encoding quirks from mail clients and services of 2003 to 2026, in many languages. imapkit --corpus downloads it once and serves it as a realistic account, so a client can be tested against mail that is much more varied than hand-written fixtures.
imapkit -p 1143 --corpus
Downloading synthetic-email-corpus v1.0.2 messages pack (347 MB) to /Users/you/Library/Caches/imapkit/synthetic-email-corpus-v1.0.2.messages.zst
Downloaded and verified in 16.0s
Loading corpus v1.0.2 ...
Starting ImapKit ...
ImapKit successfully listening on port 1143
Corpus v1.0.2: 11,637 messages in 7 mailboxes, loaded in 1.0s
INBOX 3,500, Lists 2,583, Newsletters 623, Alerts 1,100, Invitations 369, Bounces 46, Junk 3,416
Synthetic Email Corpus by Postal Systems, CC BY 4.0, https://github.com/postalsys/synthetic-email-corpus
Log in with testuser / testpass as usual. The corpus is licensed CC BY 4.0, the attribution line says where it comes from.
Versions and the cache
Every ImapKit release pins one corpus release and its SHA-256 digest, so --corpus always serves the same messages with the same UIDs until you upgrade ImapKit, and it makes no request at all once the release is cached. Other releases are explicit:
| Option | Release |
|---|---|
--corpus | The release pinned in this ImapKit version (v1.0.2) |
--corpus=v1.0.2 | That release (1.0.2 works too) |
--corpus=latest | The newest release, looked up with the GitHub API on each start |
Every corpus release has two downloads: the full archive (422 MB, with the oracles and images) and a messages pack (347 MB, only the messages, the broken variants and their manifests in one zstd stream). ImapKit downloads the pack, which also loads about twice as fast (1 second instead of 2 for the whole corpus). zstd is built into Node.js from version 22.15, Bun and Deno; on older Node.js versions ImapKit downloads and reads the archive instead. When the cache already holds the archive (ImapKit 5.5 downloaded it), it is used as it is, and imapkit corpus pull adds the pack.
The release is downloaded once into the cache directory: ~/Library/Caches/imapkit on macOS, $XDG_CACHE_HOME/imapkit (or ~/.cache/imapkit) on Linux, %LOCALAPPDATA%\imapkit\Cache on Windows, or IMAPKIT_CACHE_DIR. A download goes to a .part file first, continues from there when it was interrupted, and is checked against the digest GitHub published for the release before it gets its name. The server reads the messages straight from the downloaded file, nothing is extracted. In CI, cache that directory between runs, or download in a step of its own with imapkit corpus pull.
Mailboxes and UIDs
Mailboxes come from the corpus manifest, which records for every message the category it was classified into and whether it came from a spam folder:
| Mailbox | Messages |
|---|---|
INBOX | personal, business and transactional mail |
Lists | mailing list and forum messages |
Newsletters | newsletters and promotions |
Alerts | automated system and monitoring alerts |
Invitations | calendar and event invitations |
Bounces | delivery failure reports |
Junk | every message that came from a spam folder, also those that read like business or personal mail. With the SPECIAL-USE plugin it has the \Junk attribute |
A thread stays in the mailbox of its first message, so a personal reply to a list message is in Lists next to the message it answers. UIDs follow the corpus ids within each mailbox (UIDVALIDITY 1), and the internal date of a message is the date of its Date header, in the zone of the header, so SINCE, BEFORE and SORT by arrival behave like a real account. Messages are not flagged, they are all unseen.
--corpus-mutations adds the 1,124 deliberately broken variants of the corpus (NUL bytes, broken quoted-printable, lost boundaries ...) in a Broken mailbox, for testing how a client copes with damaged mail.
Finding messages
imapkit corpus find shows where --corpus serves the messages that match a filter, read from the manifest without loading the messages:
imapkit corpus find ew:koi8-r/B --limit=3
ID MAILBOX UID CATEGORY LANG THREAD
sc-000583 Junk 279 list ru
sc-000599 Junk 294 spam ru
sc-000611 Junk 306 list ru
35 messages in v1.0.2 match, showing 3 (--limit=0 shows all)
A filter is a list of key:value terms. Terms with the same key are alternatives, terms with different keys must all match, so category:spam category:list lang:et finds Estonian spam and list mail. The keys are id, category, lang, thread (a thread name, any or none), spam (true for messages from a spam folder), folder (the mailbox) and the feature tags of the manifest: ct (content type), cs (charset), cte (transfer encoding), ew (encoded words, ew:koi8-r/B), ext (attachment extension), size and quirk. The corpus README lists the tags. --json prints the matches as JSON, for use in test setup.
The same filter limits what the server loads: --corpus-filter=lang:et serves only the Estonian messages. Filtered messages keep the mailbox and UID they have in the whole corpus, and every mailbox exists also when the filter leaves it empty, so a test written against a filtered server works against the full one.
Commands
| Command | Does |
|---|---|
imapkit corpus pull [version] | Downloads a release into the cache and prints its path |
imapkit corpus list | Lists the cached releases (--json for JSON) |
imapkit corpus find <terms...> | Shows mailbox and UID of the matching messages (--limit, --json, --corpus=<version>) |
imapkit corpus clean [version] | Removes cached releases and partial downloads |
The server options are --corpus[=version], --corpus-filter=<terms> and --corpus-mutations, or IMAPKIT_CORPUS (true or a version), IMAPKIT_CORPUS_FILTER and IMAPKIT_CORPUS_MUTATIONS=true, or a corpus key in the config file (true, a version, or { "version", "filter", "mutations" }). --corpus can not be combined with --storage or --maildir.
From code
imapkit/lib/corpus does the same in a test setup:
import imapkit from 'imapkit';
import { loadCorpus } from 'imapkit/lib/corpus';
// downloads the pinned release on the first run, reads it from the cache after that
const corpus = await loadCorpus({ filter: 'lang:et' });
const server = imapkit({ plugins: ['SPECIAL-USE'], storage: corpus.storage });
await server.start(1143);
// the mailbox and UID of a message with a KOI8-R encoded word
const [{ path, uid }] = corpus.find('ew:koi8-r/B');
loadCorpus() takes version, filter, mutations, dir (the cache directory) and onProgress. The result has storage, counts (messages per mailbox), entries (the manifest) and find(terms).
The whole corpus takes about 1 GB of memory once a client has fetched every message. When the Node.js heap limit is below 1.5 GB, imapkit --corpus prints a note on how to raise it (NODE_OPTIONS=--max-old-space-size=4096).