Personal Mail and Alias: My Gmail Replacement, One Address per Service
I wanted a separate email address for every service I sign up to, and a server that cannot read the mail it stores. So I built my own mail service to replace Gmail.
I built it to take back my freedom, privacy and security. I don't trust big tech with my mail.
It has been my main inbox since February 2026. It is more than a client: a web app, an email worker that receives and sends, a database schema, a bridge for desktop mail apps, and tests. It supports several accounts.
One address per service
In the app, aliases are called names. When I sign up for something, I create a name for it, either one I choose or 12 random characters, and file it under a group. If a name starts getting spam, I switch it off or delete it. My real address is never handed out.
In September I had 33 names in three groups, so I rebuilt the inbox around them. Each group is a filter, and replies leave from the name the mail came to. I also removed what I did not use: after six months I had two labels, none applied, and zero templates, so both went.
Routing is one function, shared by every way mail gets in: an exact match first, then a check for deleted names, then wildcard patterns, then the catch-all. Deleted names leave a SHA-256 tombstone, so an address I once gave to a bank can never be issued to someone else and receive its password resets.
How mail arrives
Cloudflare Email Routing is the MX for my domain. It passes each message to my email worker, which:
- finds the name, and bounces unknown, deleted, expired or disabled ones
- rejects a message whose SPF and DKIM both fail
- parses the MIME parts, scores spam and builds a preview
- seals the envelope and body to my public key and writes the ciphertext to D1
The worker holds only the public key, so it cannot read back what it wrote.
sender's mail server -> Cloudflare Email Routing (MX) -> email worker: route, verify, parse, seal -> D1: ciphertext + routing metadata -> my browser: unlock vault, unseal, render
The encryption
Each message gets a fresh AES-256-GCM key, wrapped to my mailbox identity with X-Wing, a hybrid of ML-KEM-768 and X25519. An attacker has to break both. The identity's secret key sits behind a random mailbox key, which is wrapped by keys derived from my vault passphrase (Argon2id), a 24-word recovery phrase, or a hardware key. Unwrapping happens only in the browser.
For search, my browser turns words into keyed BLAKE2b tokens and uploads only those. Drafts, contacts and attachments are sealed too. The construction is written up as a spec with known-answer test vectors.
The vault came after the mailbox. In August I migrated every stored message into sealed form from my browser, then deleted the old server-side key. Snapshots from before that day can no longer be read by anyone.
What the server can and cannot see
Is this end-to-end encryption? For most of my mail, no, and I would rather say so plainly.
Mail from the outside world arrives over SMTP. The worker has to read it to parse and seal it, so Cloudflare and my worker see each incoming message in plaintext while it is processed. Changed ingest code could read new mail as it arrives, though mail already stored stays sealed. Mail I send to outside addresses reaches the relay in the clear too.
Mail written in the web app to another account on the instance is different: the sender's browser seals it to the recipient's public key, so the server never sees it. The limit: those keys come from my server, and there is no key transparency yet to prove they are the right ones.
The server also sees what it must act on: arrival time, size, folder and read flags, the Message-ID, which name received each message, and the authentication verdict. It serves the web client too, so a malicious update could steal the vault on unlock. Each build publishes its file hashes, and a small browser extension checks what was served against them.
And if I lose both the passphrase and the 24 words, the mail is gone. There is no reset.
Running it
My instance runs on Cloudflare: the Next.js app on Workers through OpenNext, the email worker beside it, D1, and a 15-minute cron for scheduled sends and retention. I deploy by hand with one script: export D1 to a backup, set a Time Travel bookmark, rehearse the schema upgrade on a copy, deploy the app, let it migrate, deploy the email worker.
The free plan has taught me things. On 24 October a search re-index spent the day's D1 write allowance in an hour, and two incoming letters bounced. Now, when D1 refuses writes, the message waits in KV under a server key and the next cron run seals it. For those hours the server could read it, which beats a bounce. The next day the CPU limit cut off about one page load in four, so identical pages now come from the edge cache in about 3 ms instead of 20.
A bridge on my own machine serves IMAP, POP3 and SMTP on 127.0.0.1 for desktop mail apps and unseals locally. The same code also runs on a Debian server with Postfix, rspamd and Caddy, scripted and rehearsed on a VM against 73 checks, but not in production yet.
There are 81 unit-test files, including the crypto vectors, and 53 Playwright specs across Chromium, Firefox and WebKit. One delivers an attachment, then scans the database files on disk for its bytes.
What I'd do next
- Move receiving to my own server, so Cloudflare no longer handles the SMTP leg. The setup is rehearsed; the hardware is not ordered yet.
- Add key transparency to the member directory.
- Test the IMAP bridge against real Thunderbird and Apple Mail. Its unit tests include a real IMAP session over a socket, but no live client yet.
- Get an outside security audit. Until then, the spec and its tests are the evidence.