Web · In daily use · 2026

Mailflare

My own email system on Cloudflare, forked from an open-source project and rebuilt: it sorts my mail, shows me only what matters, drafts the replies and files the paperwork.

Cloudflare Workers · D1 · R2 · Queues · Workers AI · Email Routing · Paperless-ngx

Email is where the small chores of life pile up: a letter from the tax office, a question from the insurance, a contract that needs cancelling before a deadline. None of it is hard. All of it takes time. So I built an inbox that does the first pass for me.

The starting point

Mailflare is an open-source, self-hosted email inbox for your own domains, built on Cloudflare and licensed under the AGPL. Out of the box it already sends and receives mail, has folders, rules, a calendar and an AI assistant.

On 10 October 2026 I forked it and started making it mine. Three and a half weeks later the fork looked like this:

Own changes since the fork 151 commits
Files touched 868
Lines added / removed about 49,700 / 8,300
Written down along the way more than 60 design notes, audits and runbooks

Like everything on this site, it was built with AI coding agents: I decided what the inbox should do and how it should feel, the agents wrote the code, and nothing shipped without tests and a review round.

How it runs

Everything lives in my own Cloudflare account. There is no server to look after.

  • Receiving: Cloudflare Email Routing hands every incoming message to the app.
  • The app: a Cloudflare Worker serves the interface and the API.
  • Storage: messages and metadata in D1 (SQLite), the raw mails and attachments in a private R2 bucket.
  • Background work: sorting, imports, Paperless uploads and bulk actions run as durable jobs in Cloudflare Queues, so they finish even when no browser is open.
  • AI: Workers AI for sorting and writing help, close to the data.

What I added

A smart inbox that stays careful

New mail is sorted into Primary, Promotions and Social, plus categories for invoices and orders. A message can carry several labels at once, labels can be nested, and a rules engine with AND/OR conditions handles the cases I can describe myself.

When I correct a category, the inbox learns from it. One click on "Always use this category for this sender" and it sticks.

The most important rule is about what must not happen: important mail must never disappear into a promotions folder. So the sorting is deliberately conservative:

  • When the model is unsure, the message stays in Primary.
  • Payment demands, legal deadlines and account security alerts get a protected path into Primary before any bulk sorting runs.
  • If the AI is unavailable or its daily limit is reached, mail simply stays in Primary.

Sorting with Cloudflare's decision models

For the sorting itself I compared three of Cloudflare's new decision models on a set of German and English test cases. All test mails were synthetic; no real mail left the inbox for this.

Model Correct destination Important mail misfiled Median response
Clef Flash 26 of 48 0 489 ms
Clef 34 of 48 0 389 ms
Clef Omni 34 of 48 0 315 ms

Clef Omni won: as accurate as the largest model, cheaper and the fastest. Most of the remaining "misses" are messages it kept in Primary to be safe, which is exactly the trade-off I want.

Writing help in my voice

  • Draft replies that take the whole conversation into account, not just the last message.
  • Polish a selection or the whole text in German or English, applied right in place.
  • A personal writing tone, so suggestions sound like me, with the writing model selectable per person.
  • The assistant can prepare a mail, but it never sends on its own: it creates a draft and I confirm it.

Paperwork goes straight to Paperless

Giving an email the label Paperless sends every PDF attachment to my self-hosted Paperless-ngx archive, each as its own background job. Only when Paperless has confirmed every document does the mail get a "processed" label. Nothing is uploaded unless I ask for it, and old mail is never scanned behind my back. This is what makes the tax office, the insurance and contract cancellations so much less painful: the documents and the facts a reply needs are already in one place.

An app on the phone

Mailflare installs on the iPhone and iPad home screen like an app:

  • Push notifications with sender and subject, and the unread count on the app icon.
  • Swipe to archive, pull to refresh, a reading pane on larger screens.
  • A fully responsive layout, tuned until every control stays within thumb reach.

Moving out of Gmail

Years of mail don't move by themselves. The fork can connect to Gmail securely and import a whole mailbox, read large Google Takeout archives, and keep syncing sent mail in the background. All imports can be paused and resumed, and imported mail is sorted by the same careful AI in a background job.

Fast on purpose

Speed was a goal, not a side effect. Startup requests were cut down, the first message is prepared while the app is idle, folders load ahead of time, and performance budgets are measured in tests. The result feels at least as fast as Gmail to me, often faster.

Small things that make a big difference

  • Password-protected PDFs open locally, right in the browser.
  • Wallet passes open as passes, not as unknown files.
  • Sender logos, compact list density, and "mark the whole folder as read" that runs safely in the background.

Safe to run every day

  • Two layers of backup: Cloudflare's 30-day database history, plus an encrypted weekly rescue copy of the database and all files in a separate storage bucket. The key to decrypt it only exists on my own device.
  • Keeping up with the original project: a weekly job compares my fork with upstream and reports what changed, without ever merging anything automatically. Security fixes from upstream are reviewed and ported by hand.
  • Browser tests run on every change, so a broken button on the phone gets caught before it reaches me.

What's next

A local version, so I can read and work through my email when I'm offline, and have it sync back as soon as I'm connected again.


Mailflare was created by hieunc229 and is licensed under the AGPL-3.0. My fork keeps the original license and copyright notices. Thanks for a great foundation.

Next project

Pimp my Kindle

A retired Kindle Oasis became my distraction-free reader for books and my whole Obsidian vault, light enough to carry everywhere and happy by the pool.