Thursday, November 26, 2026

Universal Email Archive

Your Email History Should Not Depend on an Inbox

Email archives tend to become the least portable part of a digital life. One provider may shut down, a workstation may disappear, or an old PST file may remain usable only inside an increasingly unavailable version of Outlook. This project turns email from many common sources into a durable, searchable, Gmail-like website that can be copied, shared, or opened entirely offline.

All the scripts discussed can be downloaded from GitHub. The optional readpst utility is available for Linux and can be installed with brew on macOS.

The archive is built from standard .eml files. There is no database server, no inbox account to keep active, and no dependency on a hosted email provider after conversion. The resulting HTML can live on a laptop, external drive, private network, or long-term backup.

One workflow, several starting points

Start with the mailbox format you have:
  • getmail.py downloads mail through IMAP.
  • mbox2archive.py converts Apple Mail or Thunderbird exports.
  • pst2archive.py imports readpst output or another tree of EML messages.
Each converter produces the same practical structure: folder metadata, message metadata, and original or reconstructed .eml files. eml2html.py then turns that structure into static HTML.


Because the final site is a directory of ordinary files, it works from a local disk or `file://` URL. It can also be deployed to a private web server or opened by anyone who has been given the archive folder.


Practical use cases


Preserve a family or personal email history

An account can contain many years of photographs, booking confirmations, school notices, medical correspondence, and conversations with relatives. The scripts preserve those messages as individual EML files while producing a friendly interface for reading them later.


Prepare for a provider or device migration

Before changing providers or replacing a computer, download or convert the mailbox once, check the HTML archive, and retain the original EML files. The static copy provides an independent view of the records without requiring the new provider to have a matching folder structure.


Handle a legacy PST archive

Outlook PST files are useful to protect, but opening and searching them often depends on a particular Outlook installation. Exporting the PST with readpst and running `pst2archive.py` makes the content available as standard EML files and a browser-based archive.


Move Apple Mail or Thunderbird mail out of an app

An mbox export can be converted with `mbox2archive.py`, preserving folder
names and message headers while making the mail immediately browsable.
Deduplicating repeated messages is optional and useful for overlapping
backups.


Create a private, searchable knowledge base

Email often contains contracts, invoices, project decisions, account details,
and technical context that is difficult to find inside a conventional inbox.
The generated search index makes this material accessible without uploading
it to an external search or indexing service.

What the resulting archive feels like

The HTML renderer provides:
  • a folder sidebar with nested folders and message counts;
  • a message list sorted from newest to oldest;
  • individual reading pages with sender details and attachments;
  • a global full-text search page;
  • container pages for folders that contain only subfolders;
  • direct links to original EML files.

The preview above shows the generated interface with 12 example messages.
Senders, subjects, dates, and folder names are only illustrative.


EML as useful intermediate format


EML is the standard representation for one RFC 822-style email message.
Keeping an EML copy means the archive is not trapped by the project's own
metadata or HTML format. Headers, bodies, attachments, and MIME structure remain available for other tools or future migrations, our to upload it to an IMAP server again.

The metadata files make browsing convenient, but the EML files remain the
portable source of truth. This separation also makes incremental workflows
possible: convert mail now, inspect it later, and rerender HTML after changing
the presentation or search configuration.


A typical command sequence


From a live IMAP account:

python3 getmail.py config.json
python3 eml2html.py --archive ./archive --out ./html

From an mbox export:

python3 mbox2archive.py --src ./Emails --out ./archive --dedup
python3 eml2html.py --archive ./archive --out ./html --copy-eml

From a PST export:

readpst -o ./pst_dump archive.pst
python3 pst2archive.py --src ./pst_dump --out ./archive --strip-root 1
python3 eml2html.py --archive ./archive --out ./html --prune-empty

Then open `html/index.html`. There is no server-side application to install,
and the HTML search works locally.