Your Email Archive Shouldn't Require Trusting Your Provider Forever
If you've ever tried to search for a receipt from three years ago, only to realize you deleted it or switched providers, you know the problem. Your email is your institutional memory, but it usually lives in someone else's house, subject to their retention policies and your own accidental clicks. Mail-Archiver is a self-hosted answer to that: a system that pulls your mail down, stores it locally, and gives you real search, export, and programmatic access on top of it.
What It Does
Mail-Archiver is an email archiving system you run yourself. It connects to your mail accounts on a schedule, syncs messages into a local store, and gives you a web UI to search, preview, and export them. It's built on .NET with PostgreSQL as the backing database and Bootstrap for the front end, and it ships as a Docker image, so deployment doesn't require assembling a stack by hand.
On the provider side, it supports traditional IMAP accounts, Microsoft 365 via the Graph API, and personal Microsoft accounts (Outlook.com, Hotmail, live.com, and M365 Family) through OAuth2 Device Code Flow. There's also an import-only account type for migrating existing archives, plus MBox and EML/ZIP import with folder structure preserved.
The interesting part for developers is the access layer. There's a read-only REST API (v1) that you authenticate with scoped, per-user API keys, so scripts can read archived mail without ever touching mailbox credentials. And there's an optional MCP server exposed over Streamable HTTP at /mcp, which surfaces the same archive to AI agents as a set of discoverable tools: search_emails, get_email, list_accounts, list_folders, and get_attachment.
Why It's Cool
The MCP server is the feature that stands out. Most "AI agent access" stories right now involve handing an agent broad credentials and hoping for the best. Here, the agent gets a read-only endpoint with a fixed tool surface. It can search and fetch, and that's it. That's a much saner security posture than giving an LLM your IMAP password and a prayer.
The REST API follows the same philosophy. Scoped per-user API keys mean you can write a script that reads a specific user's archive without ever storing their mailbox credentials anywhere. If you've ever wanted to build a personal search tool or a compliance report on top of your mail, this is the piece that makes it practical.
Multi-provider support that actually covers the awkward middle ground is another point in its favor. Personal Microsoft accounts are usually the ones that get ignored in enterprise-flavored tools, and Mail-Archiver ships with a pre-registered shared Client ID for them, so you don't have to go through Azure App Registration just to archive your Hotmail.
Other things worth noting:
- M365 Tenant Import lets you bulk-import every mailbox in a tenant from a single form, skipping existing and disabled accounts. If you're an admin dealing with offboarding or compliance, that's a real time-saver.
- Retention policies are configurable per account (30, 90, 365 days, whatever you need), with separate retention for the local archive versus the mailserver. So you can delete from the server while keeping your own copy.
- Export is first-class. You can export whole accounts or selected emails as mbox or zipped EML. No lock-in on the way out, which is the whole point of archiving.
- Mailbox migrations copy emails between mailboxes while preserving folder structure, which is the kind of feature you don't appreciate until you need it.
- OIDC authentication and multi-user support with account-specific permissions mean it's not just a single-user toy if you don't want it to be.
The dashboard includes storage monitoring and statistics, and there's detailed access logging if you care about who read what.
How to Try It
The project runs on Docker, so the fastest path is to pull the image and point it at a PostgreSQL instance. The full setup instructions live in the repository:
- Head to github.com/s1t5/mail-archiver and clone or pull the image.
- Review the provider-specific setup guides in the
doc/folder. Which one you need depends on your mail source:- IMAP accounts: standard configuration
- M365: see
doc/AZURE_APP_REGISTRATION_M365.md - Personal Microsoft accounts: see
doc/MSA_Outlook_Setup.md
- If you want API or agent access, read
doc/API.mdfor the REST layer anddoc/MCP.mdfor the MCP server. - For retention behavior, check
doc/RetentionPolicies.mdbefore you let it start deleting anything.
There's also a project website at mail-archiver.org and a public roadmap linked from the README if you want to see where it's headed.
Final Thoughts
Mail-Archiver is best suited to people who already self-host things and want their mail history to outlive any single provider relationship. It's not trying to be a full mail client or a replacement for your inbox; it's an archive, and it takes that job seriously with export formats, retention controls, and a clean read-only access model. The MCP integration is a thoughtful addition that treats AI agents as untrusted readers rather than privileged users, which is the right instinct. If you've been meaning to get your email out of the cloud and into something you control, this is a solid place to start.
Follow @githubprojects for more developer tools and open source projects.