Mailopus
Email you run in your own Cloudflare account, built on JMAP
- Client
- Personal
- Type
- JMAP SERVER / NUXT
- Year
- November 2026
- Views
Mailopus is email you run in your own Cloudflare account. I built it to get off Google Workspace: it now receives mail for about ten of my domains and holds the 18 GB of Gmail history I imported from four mailboxes. The server code is on GitHub under the PolyForm Shield license, so anyone can deploy their own copy to their own Cloudflare account and run their mail there.
The server
The server implements JMAP Core and Mail (RFC 8620 and 8621) with WebSocket push (RFC 8887), in one Cloudflare Worker. Email Routing hands inbound mail to the Worker, which parses it and stores the raw MIME in R2 as the source of truth. D1 holds the index: mailboxes, threads, keywords and an FTS5 search table. Each account gets a Durable Object that serializes every write, hands out the change counters JMAP state is built from, threads replies, and holds the sockets that push new mail to every open client. Any JMAP client can connect and get push, not just mine.
Outbound mail goes through Email Sending, one copy per recipient with Bcc stripped. Scheduled send uses SMTP HOLDUNTIL: held mail waits in a Scheduled mailbox until the Durable Object's alarm sends it, and canceling moves it back to Drafts. Deletes leave tombstones so clients can sync them, and a job purges the tombstones after 30 days.
Search got rebuilt during the launch review after heavy searches overloaded D1. A rare word now costs one database round trip and loads full rows only for the page it returns, and a common word walks the mailbox by date instead of reading every match. The server logs search timings without ever logging the words.
Moving off Google
The Gmail importer reads each Workspace through a dedicated service account limited to four read-only scopes, and imported mail goes through the same ingest path as new mail. Every address from both Workspaces became a send-as identity with an exact inbound route, so unknown addresses still bounce the way Google bounced them. Eight domains cut their MX over to Email Routing on November 6, 2026, with SPF extended rather than replaced and DMARC left as it was. One domain's zone moved between Cloudflare accounts to get Email Sending without paying for a second plan, and its website moved with it.
The web app
The app is a Nuxt 4 single-page app that installs as a PWA, with an unread badge on the app icon and push notifications. Desktop gets three panes, and phones get one pane at a time with swipe actions, long-press select and a strip for mailboxes. The list has bulk select, stars, labels, search that filters loaded mail as you type, an unsubscribe button for list mail, and an undo stack on Command+Z.
HTML mail renders in a sandboxed iframe with no scripts or forms and a content policy that blocks every network load, so tracking pixels never fire. Remote images load through an image proxy. Compose docks bottom-right or beside the thread you're replying to, edits markdown visually in Tiptap or as plain text, and sends both text and HTML parts. It handles attachments, pasted inline images, forwards with the original attachments, and per-address signatures.
Swiftly signatures
Mailopus is a signature target for Swiftly, my signature manager, the same way a Gmail mailbox is. Connecting is an OAuth authorization code with PKCE: the browser goes to swiftly.biz to approve, and the Worker swaps the code for an agent token server-to-server. The token is stored once per account, stays on the Worker and never reaches the browser. Signatures go through a provider interface, and Swiftly is the first provider.
For each managed address, Mailopus sends Swiftly the address and the signature it has stored, writes back exactly what Swiftly says to write, and confirms it applied. If someone edited the signature somewhere else, Swiftly refuses to overwrite it, and Mailopus records the refusal on the address. Syncs run when you save, when you press Sync now, and from a cron at most every 30 minutes per address. While Swiftly manages an address, its signature shows read-only, and disconnecting stops updates without touching the signatures.
Sign-in and security
Sign-in is passkeys, with an optional authenticator code, recovery codes, and one-time invites for each user's first passkey. A gate runs before anything else in the Worker, so only the sign-in pages load without a session, those endpoints are rate-limited, and cross-site writes get a 403. The push socket opens with a one-time ticket instead of the session token. Claiming a freshly deployed server needs a secret from that deploy. App passwords for mail apps expire, show the last network that used them, and send an alert when a new network signs in or a wrong password is tried. Before launch I ran a full security and performance review, then fixed and deployed the findings.
Mail apps, spam and plugins
Mail apps that only speak IMAP go through a proxy written in Go. It translates IMAP and SMTP to JMAP, runs on its own VM, and gets its certificates over ACME with the DNS challenge answered in another zone. Spam goes to Junk on a DMARC failure when the sending domain asks for that, on a blocked sender, or on a rule from a spam Worker or remote classifier. Hosted rules live at spam.mailopus.net, and a sample classifier is published. Plugins are Workers that hear about mail as it arrives or goes out and can file it or stop a send. The gotmail example alerts you by Slack, webhook, text message or a sound when mail you're waiting for arrives.
Shipping it to other people
The public server repo is a snapshot that a publish script builds from the private one. It leaves out private notes and the end-to-end tests, and it checks compiled binaries for private markers. Customers deploy with the Deploy to Cloudflare button or the mailopus CLI on npm, which also handles users, invites, addresses and plugins, and the customer Worker builds the server without the UI. Releases are tagged, a person approves every server update, and new dependencies wait three days before they're allowed in. Documentation is at docs.mailopus.net. About 240 server tests run on node:sqlite against the real migrations, plus Go tests for the proxy and an end-to-end run that includes a Gmail import against a stand-in for Google.