Skip to content
Tinbox

The blog

Engineering notes on owning your email stack

Deep dives, honest comparisons, and field notes on running your own inbox, sender, and newsletter on Cloudflare. 131 articles

Idempotent email sending so users never get duplicate receipts
tutorialsNov 27, 2026

Idempotent email sending so users never get duplicate receipts

Duplicate transactional email is one of those bugs that never shows up in dev and always shows up the week you get traffic. It is rarely a bug in the email code. It is a bug in the assumption that the thing which triggers the email happens exactly once. It does not. Buttons get double-clicked, requests get retried, queues redeliver, and operators replay. Every one of those paths can fire your send a second time.

Latest

Conversation pages fold into a concise briefing card.
tutorialsNov 20, 2026

Summarize long email threads with an AI sub-call

To summarize a long email thread with AI, fetch the thread's messages in chronological order, render them into a single bounded prompt (sender plus body per message, truncated), and make one LLM sub-call with a system prompt that asks for the participants, the ask, the current state, and what needs a response. A 40-message thread becomes one model call. The interesting engineering is not the call itself, it is bounding the input so you never overrun the context window and never accidentally feed the whole inbox into the prompt.

Indexed message cards reveal one searchable email record.
tutorialsNov 18, 2026

Full-text email search with SQLite FTS5

If you are storing email in SQLite or Cloudflare D1, you eventually need search, and the instinct is to reach for WHERE body LIKE '%invoice%' . That works on a hundred rows and falls over on a hundred thousand: it scans every row, it cannot rank, it has no concept of word stems, and it lights your database CPU on fire. The correct tool has been sitting inside SQLite the whole time. It is FTS5, the full-text search extension, and email is close to its ideal workload: lots of text, read-heavy, and you want relevance plus snippets, not just a boolean hit.

A message moves from dispatch through a check to a recipient tray.
tutorialsNov 16, 2026

SMTP relay from Cloudflare Workers: the 2026 capability boundary

SMTP is the oldest reliable thing in the email stack. You have a relay host, a port, a username and password, and a library that speaks the protocol. It has worked on every server you have ever run. Then you move the same code onto a Cloudflare Worker and it stops cold, with errors that look like networking flakiness but never resolve on retry.

Interlocking email tool modules illustrate a composable developer interface.
tutorialsNov 13, 2026

One Zod tool manifest for MCP, chat, and CLI

If you expose the same capabilities to an in-app AI chat, to an external MCP client like Claude, and to a CLI, the naive path defines each tool three times. That triplication is where drift lives: a parameter gets renamed in the chat tool but not the MCP one, the CLI validates differently from the agent, and the descriptions slowly diverge until the model and the human are working from different mental models of the same action.

An ivory letter protected by three nested authentication arches.
tutorialsNov 11, 2026

Set up MX records to receive mail on your own Cloudflare inbox

Receiving email is a DNS problem before it is a code problem. A sending server has no idea your inbox lives on Cloudflare. It asks DNS one question: "what is the MX record for this domain?" and delivers to whatever that record names. If the answer is missing, points at a dead host, or still names a Google Workspace you cancelled, your mail never reaches your Worker no matter how perfect the handler is. This guide walks every record from first principles, shows the failures you will actually hit, then notes how npx tinbox init publishes the same set for you. For the higher-level sequence this fits into, the steps to receive inbound email on your own Cloudflare account is the map, and the DNS records every sending domain needs covers the outbound half you will add once you also send.

Interlocking email tool modules illustrate a composable developer interface.
tutorialsNov 9, 2026

How to send email from a Next.js app on Cloudflare

To send transactional email from a Next.js app deployed on Cloudflare, the most portable path is a Worker-native binding or HTTPS API from a route handler or Server Action. Workerd exposes outbound TCP, but not Node's full socket runtime; Node-oriented SMTP packages such as Nodemailer are therefore not automatically compatible, outbound port 25 is blocked, and Cloudflare-owned SMTP endpoints are unreachable over Worker TCP. Use a Worker-native helper or fetch() unless you have deliberately chosen and tested a runtime-compatible third-party submission client.

A buffered sequence of messages includes a safe retry loop.
tutorialsNov 6, 2026

How to send bulk email in batches from a Cloudflare Worker

Sending one transactional email from a Worker is easy. Sending fifty thousand is a different problem, and the difference is not the email, it is the loop. The instant you await a send inside a single request handler, you have tied a long, failure-prone job to one invocation that Cloudflare will not keep alive long enough to finish.

Conceptual textless workspace panels show a queue, reading pane, and context.
tutorialsNov 4, 2026

Self-hosted webmail: a Gmail-style inbox you host on your own domain

When developers say "self-hosted email," they usually mean the plumbing: MX records, a mail server, maybe an API to send. The part that gets quietly dropped is the inbox itself, the human-facing UI where someone actually reads a support thread, searches for last month's receipt, and hits reply. That UI is the hard, unglamorous part, so most self-hosted email projects ship an API and tell you to bring your own client (Thunderbird, Apple Mail, a webmail package you bolt on separately).

One newsletter connected to three distinct audience groups.
tutorialsNov 2, 2026

A self-hosted newsletter tool with no per-contact tax

This is a walkthrough of running a real newsletter on infrastructure you control: sending broadcasts, segmenting your audience, tracking opens and clicks, and honoring unsubscribes, all on the same contact list as your transactional mail. It assumes your list is already in your own database. If you are still on Mailchimp and need to get your subscribers out with tags and status intact first, start with migrate your existing list in first, then come back here to operate it day to day.

More articles

Segment your email list with plain SQLOct 30, 2026How to add role-based access to a shared team inboxOct 28, 2026Handle reply-by-email and keep threads intactOct 26, 2026Render React Email templates on Cloudflare WorkersOct 23, 2026RAG over email: build retrieval-augmented answers over your own archiveOct 21, 2026Parse raw MIME email in JavaScript without a heavy libraryOct 19, 2026Implementing one-click unsubscribe and List-Unsubscribe headersOct 16, 2026From zero to a running inbox with npx tinbox initOct 14, 2026How to migrate from Resend to your own Cloudflare senderOct 12, 2026Postgres to D1 migration: moving an email app to edge SQLiteOct 9, 2026Export your Mailchimp audience and bring it in cleanOct 7, 2026Add OAuth 2.1 and PKCE to your MCP serverOct 5, 2026MCP bearer token: connect Claude Code and Cursor to your mail (headless)Oct 2, 2026Mailchimp alternative, self-hosted: migrate off without losing your listSep 30, 2026Writing an llms.txt so agents understand your productSep 25, 2026Writing eval suites for LLM email classifiersSep 23, 2026LLM email classification with interpreters: rules + LLMs you can trustSep 21, 2026Import an mbox file into your own inboxSep 18, 2026How to import an IMAP mailbox into a database you ownSep 16, 2026How to import Gmail into a self-hosted database you ownSep 14, 2026Idempotent email sending: stop retries from delivering duplicate mailSep 11, 2026Build a transactional email API with Hono on CloudflareSep 9, 2026Handle inbound email attachments safely without getting ownedSep 7, 2026How to import your Gmail locally with OAuth instead of trusting a SaaSSep 4, 2026Generate and rotate DKIM keys for sending on CloudflareSep 2, 2026Email to task automation: turn inbound mail into actionsAug 31, 2026Email for AI agents: give your agent its own address and inboxAug 28, 2026Self-hosted email tracking: open and click tracking that respects privacyAug 26, 2026Build a SaaS onboarding email sequence triggered by product eventsAug 24, 2026Process bounce and complaint webhooks into a suppression listAug 21, 2026How to check SPF, DKIM, and DMARC are actually passingAug 19, 2026Email archival to R2 cold storage while keeping search workingAug 17, 2026Rate limiting your email API on Cloudflare WorkersAug 14, 2026DMARC report analysis: reading aggregate reports without a paid toolAug 12, 2026Catch spam complaints with email feedback loopsAug 10, 2026Detect OTP and verification emails automaticallyAug 7, 2026Detect important email automatically with an interpreterAug 5, 2026Designing a D1 email database schema for an inboxJul 31, 2026Wire a custom domain per tenant for client inboxesJul 29, 2026Connect Claude to your email inbox in five minutesJul 27, 2026MailChannels for Cloudflare Workers is gone: the alternativeJul 24, 2026Turn inbound email into a webhook with Cloudflare WorkersJul 22, 2026Storing email attachments in Cloudflare R2Jul 20, 2026Using Cloudflare Queues to send email reliably at volumeJul 17, 2026Cloudflare Email Routing tutorial: receive inbound mail in a WorkerJul 15, 2026Set up a catch-all address with Cloudflare Email RoutingJul 13, 2026Send scheduled email digests with Cloudflare Cron TriggersJul 10, 2026Programmable Inboxes for AI Agents and E2E TestsJul 9, 2026Connect ChatGPT and other assistants to your inbox over MCPJul 8, 2026Build a newsletter signup with double opt-in on CloudflareJul 6, 2026Your inbox is now an MCP server: connect Claude to your emailJul 2, 2026The real cost of transactional email at scale (a pricing teardown)Jun 30, 2026Resend is great. Here's when you'd self-host it instead.Jun 26, 2026Why Node SMTP fails in Cloudflare Workers — and what worksJun 24, 2026Email for vibe-coded apps: the part the agent forgetsJun 20, 2026Introducing Tinbox: your whole email stack on your own Cloudflare accountJun 18, 20266 Myths About Sending Email From Cloudflare WorkersJun 16, 2026How to build an MCP server on Cloudflare WorkersJun 15, 20265 Smart Ways to Use Cloudflare R2 in an Email StackJun 13, 2026BIMI setup: show your brand logo in the inboxJun 13, 2026