munchymail a mail archive that keeps every copy of every message

Mail archive · self-hosted · built for people and agents

Every copy of every message, kept.

munchymail gathers mail from live mailboxes, old backups and Gmail into one archive and keeps it current as mail arrives. It keeps each message byte for byte, remembers every place it was ever found, and lets you search all of it, from your terminal or through an AI agent.

Mailboxes forget. Folders get reorganised, filters move things, a backup from three years ago holds the only copy of something that mattered. munchymail reads all of it and forgets nothing.

History

Search the whole history

Every message, every folder it was ever in, and when it arrived or left. Search headers, text, attachments and scanned documents across every account.

Live

Follow mail as it arrives

Gmail and IMAP mailboxes are kept current within seconds to minutes. Every arrival, move, deletion and flag change becomes history, and backups sit alongside as snapshots.

Index

Index the bytes, not the folders

Messages are stored by the hash of their exact bytes. Folders, labels and duplicates are interpretations laid on top, and can be rebuilt.

munchymail never writes to a mail source. It reads IMAP folders with EXAMINE and BODY.PEEK (not even \Seen changes), mbox files under the same shared lock a Dovecot reader takes, and Gmail with a read-only sign-in, and writes only its own data directory.

Searchable history

Everything munchymail has seen stays searchable, including mail that has since been deleted, moved or filtered away.

munchymail search --participant '*@accountant.example' --since 2024-01-01
munchymail search --text '"tracking number" -amazon' --attachment pdf
munchymail changes --origin mailhost-dovecot
munchymail read m1834

Live syncing

The service keeps every live origin current by itself, and remembers what it saw on the way.

munchymail sync
munchymail overview
munchymail removals --folder INBOX

Snapshots of live sources

A source is an origin: a live mbox tree, a backup found on an old disk, a Google Takeout, a Gmail account. Each has a role (live, snapshot or export), and each import of it is recorded as a run.

A different kind of index

Most mail tools treat the folder tree as the truth. munchymail treats the exact bytes of each message as the evidence, and everything else as an interpretation of them.

Layer What munchymail keeps
object bytes by SHA-256; small ones inside SQLite, large ones in a content store
artifact one exact message: its header bytes and body bytes, hashed separately
observation where a copy sat: the file, the byte offset, its mbox From line
message one email however many copies exist; its id (m1834) survives Dovecot rewriting its headers
derived decoded headers, MIME parts, full text, OCR: versioned and rebuildable

And because every copy is kept with how it was framed, the original mbox files can be rebuilt from the archive alone: mmadm verify-files rebuilds each one and checks it against the hash recorded when it was read.

Damage is noted, not hidden: a copy whose body is shorter than its server recorded, a multipart message cut off before its end, or a copy that is the start of a longer one is marked as such (search --mark), with what was measured, so the intact copy, if the archive has one, can be found. Once its owner has judged a copy damaged (mmadm copy damaged), it leaves search and the indexes but is still kept and readable, with the reason and the copy that repaired it.

Because storage is deduplicated but history is not, a message seen in nine backups is stored once and remembered nine times. When copies differ only in the headers a mail server adds, they are still one message; when an export damaged a copy, the archive records why the two were joined.

The same email read from an mbox file, over IMAP, from the Gmail API and from a Takeout is one message: the differences each store makes (line endings, how a NUL byte travels, the newline an mbox adds) are read alike, and nothing else is. Message ids never change meaning: a message whose copies joined another points to it, and no id is reused. The rules, and why they are safe, are in Identity and duplicates.

Made for agents too

An agent can search and read the archive as easily as a person can, and can’t change anything it wasn’t asked to.

munchymail describe --json lists every command, its arguments and whether it only reads or writes. search --json returns JSON Lines with stable paging, and read --json marks every message’s content as untrusted, so an agent treats mail as data, never as instructions.

The archive runs as a small service on a Unix socket, so searches answer while a long import or OCR run carries on, and the setup commands live in a separate program, mmadm, that agents leave alone unless asked.

Just getting started

munchymail already keeps, searches and exports a lifetime of mail. Next: