localmail
Free & open source

Your mail,
on your terms.

localmail mirrors every IMAP account you own into a local PostgreSQL database and a content-addressable file tree. Searchable, scriptable, and yours — never deletes, modifies, or sends mail upstream.

localmail logo
Why localmail

An archive built for the long term.

Mail providers come and go. Your archive shouldn't. localmail keeps every byte you've ever received in a database you fully control.

You own the archive

Plain PostgreSQL. Plain files. Standard formats. Inspect, back up, export, or grep your mail any way you like — no proprietary blob, no lock-in.

Read-only upstream

localmail never deletes, modifies, or sends mail. The IMAP server is treated as the source of truth; the mirror is strictly downstream of it.

Hybrid search

Lexical full-text plus vector embeddings, fused with reciprocal rank fusion. Searches message bodies and the text inside PDF, DOCX, XLSX, and 8 other attachment formats.

Multi-account

Mix Gmail (OAuth2), Microsoft 365, Fastmail, Proton Mail (via Bridge), iCloud, self-hosted, anything that speaks IMAP. Per-account sync threads, per-user access control.

Secrets in the keyring

Passwords and OAuth refresh tokens live in macOS Keychain or Linux Secret Service — never in a config file, never in the repository.

Dedup & content-address

Attachments are stored by SHA-256 — the same PDF sent to ten different accounts lives on disk exactly once. Original filenames preserved per-message.

Quickstart

From zero to mirrored mail in about an hour.

Three short steps in the user manual walk you through it, from a blank machine to a running archive:

  1. Set up PostgreSQL (Docker or native).
  2. Install the localmail CLI with uv.
  3. Add your accounts (Gmail, Outlook, Fastmail, Proton, …).
# 1. Install uv (the Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh

# 2. Install localmail globally
uv tool install --python 3.12 \
  --from git+https://github.com/hherb/localmail \
  localmail

# 3. Drop in a config & init the database
curl -fLo ~/.config/localmail/config.toml \
  https://raw.githubusercontent.com/hherb/localmail/main/config.example.toml
localmail init-db

# 4. Add an account & sync
localmail add-account work-fastmail
localmail sync --account work-fastmail
Three ways to use it

Pick the interface that fits.

Same archive, same hybrid search index, three front ends — each documented in the manual.

Built for privacy

Your mail never leaves your machine.

No upload, no third-party indexer, no telemetry. Search runs locally against your own database. Embedding model downloads once and runs offline thereafter.

  • Local-first. Postgres on your machine or LAN; attachments on your disk.
  • OS-native secrets. Keychain on macOS, Secret Service on Linux.
  • No SaaS dependency. Gmail's OAuth flow uses your Google Cloud project.
  • Auditable. Python + PostgreSQL + standard libraries. Read the code; run the tests.
  • Source-available, freely licensed. Hack it, fork it, audit it.