Section
Tutorials
Step-by-step, hands-on guides for standing up and operating your own email stack on Cloudflare. 74 articles
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
Segment your email list with plain SQL
A segment is a question about your subscribers: who do I want to mail this time? SaaS platforms answer it with a point-and-click builder, which is fine until the question gets specific. The moment you want a NOT EXISTS, a self-join, your own date math, or a condition the dropdown does not offer, you are stuck, because you are renting an interface to your data instead of holding the data.
How to add role-based access to a shared team inbox
Role-based access is one of the things that separates a toy shared mailbox from a real one; the features a self-hosted team inbox should have puts it alongside the rest of the list, and for teams in regulated environments the reasons regulated teams self-host their email explains why owning the audit trail matters even more.
Handle reply-by-email and keep threads intact
Reply-by-email is one of the highest-leverage features in any product that emails people: a support ticket that a customer can answer from their own mail client, a comment notification they can reply to, a digest they can respond to inline. The hard part is not receiving the reply (covered in turning inbound mail into a webhook); it is attaching that reply to the right conversation so your inbox shows a coherent thread instead of a pile of disconnected messages.
Render React Email templates on Cloudflare Workers
To render React Email templates inside a Cloudflare Worker, call the async render() from @react-email/render , fix the bundler by adding nodejs_compat (or marking react-dom external), and keep heavy rendering off the request path by precompiling static templates to HTML at build time. React Email is built on react-dom/server , which can run on workerd, but the library and its transitive dependencies assume Node in a few places that you have to work around.
RAG over email: build retrieval-augmented answers over your own archive
Retrieval-augmented generation (RAG) is the third path: find the handful of messages that matter, then let a language model read only those and answer. This guide builds the whole thing by hand on Cloudflare (D1 + an LLM call), honestly, including where keyword retrieval falls short. Then it shows where Tinbox does the same work for you if you would rather not assemble it. For the bigger picture of what this unlocks once it works, see the things RAG over your email unlocks.
Parse raw MIME email in JavaScript without a heavy library
When an email arrives at a Worker through Cloudflare Email Routing, you get the raw message: headers, a blank line, and a body that might be plain text, might be HTML, might be both wrapped in multipart/alternative , and might have a PDF and two inline logos bolted on through multipart/mixed and multipart/related . The Node ecosystem has mailparser for exactly this. It does not run on workerd. So you have two choices: find a runtime-agnostic parser, or understand MIME well enough to parse it yourself. This walks the second path in full, because once you have done it once, the libraries stop being magic.
Implementing one-click unsubscribe and List-Unsubscribe headers
One-click unsubscribe is one of those features that is trivial to describe and easy to get subtly, silently wrong. You add a header, it looks right, mail sends, and you never find out that Gmail decided your List-Unsubscribe was untrustworthy until your bulk mail starts landing in spam. There is no error. There is no bounce. The header just does nothing.
From zero to a running inbox with npx tinbox init
A normal "build your own email" project means picking a transactional API, a separate marketing tool, a webmail frontend, somewhere to store attachments, a database for messages, and an inbound parser, then writing the glue that holds all of them together. Each piece is a separate account, a separate SDK, and a separate line on your bill. npx tinbox init exists to skip that assembly: one Worker, one Cloudflare account, your domain. Here is the whole flow end to end, including what the bootstrapper writes to disk and the one step it deliberately cannot do for you.
How to migrate from Resend to your own Cloudflare sender
To migrate from Resend to a self-hosted Cloudflare sender, you move the send behind one adapter, stand up an endpoint that speaks Resend's request shape on your own Cloudflare account, re-verify your sending domain in DNS, and cut over by changing a base URL and an API key. The send-site code barely moves because the request body is nearly identical. What you gain is ownership of the delivery path and your data, and the end of per-email pricing; the standalone case for that is in why owning your sending domain beats owning the provider.
Postgres to D1 migration: moving an email app to edge SQLite
A Postgres to D1 migration sounds like a database swap and is really a dialect port. D1 is SQLite at the edge, and SQLite is a genuinely different engine: four storage classes instead of dozens of types, no timestamptz , no jsonb , no arrays, no ILIKE , no to_tsvector . The schema concepts carry over; the syntax and the type system do not. For an email app this is mostly tractable because mail is append-mostly and read-heavy, but the migration has sharp edges, and the sharpest is data that was fine in Postgres and is illegal in SQLite.
Export your Mailchimp audience and bring it in clean
Leaving Mailchimp is mostly a data problem, not a sending problem. If you are still deciding where the list lands, the Mailchimp alternatives that don't tax you per contact is the shortlist, and the mistakes teams make when leaving an email vendor is worth reading before you start the export. The campaigns you can rewrite. The templates you can rebuild. What you cannot reconstruct is the accumulated state of your audience: who unsubscribed, who hard-bounced, which contacts carry which tags, and which merge fields hold the data your automations depend on. A careless export throws most of that away, and the worst part is that the export looks complete. You get a CSV with thousands of rows and a sense that the job is done.
Add OAuth 2.1 and PKCE to your MCP server
If you wrote an MCP server and tested it with Claude Code, you probably passed a static Authorization: Bearer header in the client config and it worked on the first try. Then you tried to add the same server as a custom connector in the Claude desktop or web app, and there was nowhere to paste the token. The app does not do static bearer auth. It speaks OAuth 2.1 with discovery, and it expects your server to be the authorization server.
MCP bearer token: connect Claude Code and Cursor to your mail (headless)
The Claude desktop app connects to an MCP server with OAuth: you click connect, a consent screen opens, you approve, done. But Claude Code, Cursor, and a CI job have no browser to open and no human standing by to approve a popup. They authenticate the boring, durable way: a static bearer token passed in an Authorization header. This article is the headless, security-focused companion to the launch post. If you want the OAuth path and a primer on what MCP even is, start with the OAuth path and what MCP is. Here we go deep on tokens: scoping them, wiring real clients, and managing their lifecycle.
Mailchimp alternative, self-hosted: migrate off without losing your list
The decision to leave Mailchimp is usually made before you start reading articles like this one. What you actually want is proof that the move will not cost you the thing Mailchimp has been holding: your audience, in the exact condition it is in today. Not just a list of addresses, but which of them unsubscribed, which hard-bounced, which carry which tags, and which merge fields your old automations leaned on.
Writing an llms.txt so agents understand your product
An llms.txt is a small Markdown file at /llms.txt that hands AI agents a curated, link-rich map of your product so they read it accurately instead of reverse-engineering your marketing site. The format is fixed and short: an H1 with your product name, a one-line blockquote summary, then H2 sections of - [title](url): description links. This guide writes one by hand, adds the llms-full.txt companion, gets the hosting right, and then shows how to generate both so they never drift.
Writing eval suites for LLM email classifiers
An LLM email classifier is code that happens to be expressed in English, and like any code it regresses. Unlike code, a one-word prompt change can flip a decision boundary you never see, and there is no compiler to catch it. The fix is the same discipline LLM teams use everywhere else: an eval suite. This is how to build one for email classification by hand, what makes email-specific evals tricky, and how Tinbox ships an eval suite attached to every interpreter so a prompt change cannot regress quietly.
LLM email classification with interpreters: rules + LLMs you can trust
If you have shopped for "LLM email classification" you have probably seen the same pattern everywhere: take the subject and body, stuff them into a prompt, ask the model for a label, store the label. It works in a demo. It falls apart in production because you have no idea when it is wrong, the cost scales with your inbound volume, and a prompt tweak that fixes one case quietly breaks five others.
Import an mbox file into your own inbox
The mbox format is older than most of the people using it. It is what you get when you export a mailbox from Google Takeout, Thunderbird, Apple Mail, or any Unix mail tool: a single plain-text file with every message concatenated one after another. It is simple enough to parse in an afternoon and just irregular enough that a naive parser will quietly mangle a fraction of your mail. This walks the full manual path first (the real edge cases, the escaping bug everyone hits, the threading problem), then shows the one-command shortcut at the end.
How to import an IMAP mailbox into a database you own
IMAP is a 1990s protocol that was designed for clients to browse a remote mailbox, not for you to bulk-export it. Every part of an import has a sharp edge: the fetch verb that silently marks all your mail as read, the UIDs that look like stable keys but are not, the messages with no Message-ID, the attachments that bloat your rows. This walks the full manual import end to end with real Node code and the real failures, then shows the local-fetch shortcut at the end.
How to import Gmail into a self-hosted database you own
Gmail is genuinely good. The search is fast, the spam filtering is the best in the business, and it almost never goes down. This is not an argument that Gmail is bad. It is an argument that the mail itself, the actual messages, should be data you own and can query directly, not data trapped behind a vendor's API that you rent access to.
Idempotent email sending: stop retries from delivering duplicate mail
Transactional email lives downstream of unreliable things. Queues deliver at-least-once. HTTP clients retry on timeout. Webhooks get re-sent. Every one of those is correct behavior, and every one of them will run your send path more than once for a single real-world event. If your send path has no memory, "more than once" means "more than one email."
Build a transactional email API with Hono on Cloudflare
A transactional email API is deceptively small: one route, some auth, a bit of validation, and a send. The deceptive part is that each of those four pieces has a sharp edge. The auth check leaks timing if you write it naively. The validation has to reject the half-valid payloads your callers will absolutely send. The send can double-fire on a retry. And the actual delivery can't be done the way you'd do it on a normal Node server, because the Workers runtime won't let you.
Handle inbound email attachments safely without getting owned
Inbound attachments are the part of an email pipeline most likely to hurt you. The body is a known quantity: text and HTML, small, easy to sanitize. Attachments are arbitrary attacker-controlled bytes with attacker-controlled names, and a naive handler does at least three dangerous things: it buffers the whole message into memory before checking the size, it trusts the declared content type, and it stores or re-serves files in a way that lets a payload reach a human or a parser. This walkthrough builds a safe inbound-attachment handler on Cloudflare Workers by hand, with the failure modes shown, then points at where Tinbox already does this so you can skip the wiring.
How to import your Gmail locally with OAuth instead of trusting a SaaS
The uncomfortable part of most Gmail importers is not the parsing, it is the access model. You click "Connect Gmail", grant a scope, and now some company holds a refresh token to your whole account and streams every message through their infrastructure. For a one-shot export, that middleman is unnecessary. The Gmail API is a plain HTTPS API, OAuth's authorization-code flow runs fine on your own machine, and there is nothing stopping the fetch from happening entirely on your laptop with the bytes going straight into your own database.
Generate and rotate DKIM keys for sending on Cloudflare
DKIM (DomainKeys Identified Mail) lets a receiver confirm that mail claiming to be from your domain was signed by someone holding your private key, and that the signed parts were not altered in transit. It is half of what DMARC needs to pass (SPF being the other half), and on a new sending domain it is non-negotiable: Gmail and Yahoo bulk sender rules treat missing DKIM as a reason to throttle or reject. It is one box on the Gmail and Yahoo bulk sender checklist you have to clear before a first campaign.
Email to task automation: turn inbound mail into actions
Email to task automation is the practice of reading each inbound message, deciding whether it implies an action, extracting the fields that action needs, and creating the task (or firing the webhook) without a human retyping anything. The mail is structured data wearing a text costume. The job is to undress it once, reliably, and route it.
Email for AI agents: give your agent its own address and inbox
To give an AI agent its own email, you provision a real address ( agent@yourdomain.com ), route inbound mail to a handler that stores it, and expose both reading and sending as scoped tools the agent can call. The agent becomes the principal: it owns the mailbox, reads through typed tools instead of a screen, and sends from its own address over an HTTPS API. This guide builds the whole thing the hard way first (MX routing, MIME parsing, a message store, an HTTPS send path, and a scoped tool layer), then shows the one-command version at the end.
Self-hosted email tracking: open and click tracking that respects privacy
Email analytics is one of the few places where the "just use the vendor" answer quietly costs you something real: every open pixel and every wrapped link in a typical campaign points at the vendor's tracking domain, not yours. That means your subscriber list, their open behavior, and their click behavior all pass through someone else's infrastructure. For a transactional receipt that might be fine. For a newsletter you are trying to keep private, or a product where subscriber behavior is sensitive, it is a leak you signed up for without noticing.
Build a SaaS onboarding email sequence triggered by product events
"Send a welcome email" is trivial. "Send a five-step onboarding sequence that branches on behavior and shuts up when the user converts" is a small state machine running once per user, and that is where the real work lives. The naive version, a cron that fires "day 3" email to everyone who signed up three days ago, is worse than nothing: it emails people who already activated, it double-sends when invocations overlap, and it keeps drip-ing users who long since converted.
Process bounce and complaint webhooks into a suppression list
Bounce and complaint webhooks are not the hard part. Providers (Resend, Postmark, SendGrid, SES) all emit them, and receiving an HTTP POST is trivial. The work is the loop after the POST: verify the payload is real, classify what kind of failure it is, decide whether the address gets one strike or several, write it to a suppression list, and (the step everyone forgets) check that list before the next send. This tutorial builds that whole loop by hand on Cloudflare Workers and D1, including the failure modes that quietly let suppressed addresses slip back into your sends. At the end, the shortcut if you would rather register the flow than maintain it.
How to check SPF, DKIM, and DMARC are actually passing
The only way to know SPF, DKIM, and DMARC are actually passing is to read the Authentication-Results header on a message that a real receiver accepted. Send a test email to an account you control at Gmail or Outlook, open the raw source, and read the spf= , dkim= , and dmarc= verdicts the receiver wrote. A green checkmark in a vendor dashboard tells you a DNS record exists. The Authentication-Results header tells you the record evaluated to pass against the IP you actually sent from, with the keys you actually signed with. Those are different facts, and the gap between them is where mail quietly goes to spam.
Email archival to R2 cold storage while keeping search working
Email is append-only and mostly cold. You read a message once, maybe reply, and then it sits there forever. The bodies, especially the HTML ones, are by far the largest part of a message and the part you almost never look at again. Keeping all of that hot in your primary database is the email equivalent of renting climate-controlled storage for boxes you will never open.
Rate limiting your email API on Cloudflare Workers
An open send endpoint is the most dangerous route in your whole app. Not because of the bill (Workers and edge sending are cheap), but because volume is reputation. Senders earn deliverability slowly and lose it fast, and a runaway loop or a stolen token can burn through years of good behavior in an afternoon. A rate limit is one of several defenses that protect that standing; the rest are in the ways to build and protect your sender reputation, and a sudden unthrottled burst is itself one of the reasons transactional email lands in spam. The fix here is a per-caller rate limit that caps how much any one client can send in a window.
DMARC report analysis: reading aggregate reports without a paid tool
DMARC monitoring services exist because the raw reports are unfriendly: gzipped XML, one per provider per day, in a schema most people never learn. Those tools charge monthly to draw you a dashboard on top of data the providers already mail you for free. The dashboards are nice. They are also not necessary to answer the only questions that matter: who is sending as my domain, and is it authenticating?
Catch spam complaints with email feedback loops
A spam complaint is the strongest negative signal a recipient can send: they actively told their mailbox provider your mail is unwanted. Bounces you can infer from delivery failures, but complaints are invisible by default. The provider knows, and your reputation score reflects it, but you are never told which message or which recipient unless you enroll in that provider's feedback loop (FBL) . This tutorial sets up FBLs for the major providers, parses the resulting ARF (Abuse Reporting Format) reports by hand, and wires the complaining addresses into a suppression list. At the end I show how a Cloudflare-native stack turns the same ARF parsing into an inbound interpreter so you never touch the MIME by hand, but the mechanics below apply no matter what you send through.
Detect OTP and verification emails automatically
OTP, 2FA, and verification emails are one of the few email categories with a clean, useful payload: a short code you want extracted and surfaced fast. The temptation is to write a five-line regex and move on. That regex works in the demo and then quietly matches Order #483920 in production. This post builds the detector properly: the two signals you actually need, the extraction logic, the eval suite that keeps it honest, and an LLM fallback for the cases regex cannot read. Then it shows the version Tinbox ships so you do not maintain any of it. OTP extraction is the friendliest of the email interpreter recipes for smarter inbound handling, so it is a good first one to wire up before the harder, tone-based interpreters.
Detect important email automatically with an interpreter
Most "priority inbox" features fail the same way: they match urgency words in the subject line, so a marketing blast that screams "Act now, deadline tonight" scores exactly as high as a real escalation. The signal that actually predicts importance is not a word, it is a relationship plus an ask. This post builds an importance classifier the right way: the three independent signals, the gate that combines them, the eval suite that keeps it from flagging everything, and an LLM escalation for the ambiguous middle. Then it shows the version Tinbox ships as an interpreter, so the verdict drives a real priority view in your inbox.
Designing a D1 email database schema for an inbox
D1 is SQLite at the edge, which is a genuinely good fit for an email inbox: mail is mostly read-heavy, append-mostly, and you want it co-located with the Worker that serves it. The hard part is not the database, it is the data model. Email has been accreting headers since 1982, threading is a graph not a tree, and bodies range from a one-line reply to a 25 MB newsletter with inline images. Get the model wrong and every list query gets slow or every thread renders out of order.
Wire a custom domain per tenant for client inboxes
A custom domain per tenant means three separate jobs, and people usually only think about the first. You need inbound delivery (mail addressed to the client's domain reaches your handler), outbound authentication (mail you send from the client's domain passes SPF, DKIM, and DMARC), and tenant resolution (a given address maps to the right client's data and nobody else's). The first two are DNS. The third is application architecture, and it is the one that decides whether you have a multi-tenant product or a security incident waiting to happen.
Connect Claude to your email inbox in five minutes
To connect Claude to your email, you expose your inbox as an MCP server and add that server as a connector in Claude. The Claude app authenticates with one-click OAuth; Claude Code uses a static bearer token. From there Claude calls typed tools (search, read, triage, send) against your inbox instead of guessing from screenshots. This walkthrough does it end to end, including the failure modes you will actually hit, and it shows the hard way (building the MCP server yourself) before the shortcut.
MailChannels for Cloudflare Workers is gone: the alternative
For about three years, the answer to "how do I send email from a Cloudflare Worker" was a single, almost magical snippet. No account, no API key, no credit card: you POSTed JSON to api.mailchannels.net/tx/v1/send and a transactional email went out. That worked because of a partnership between Cloudflare and MailChannels that gave Workers a free relay.
Turn inbound email into a webhook with Cloudflare Workers
Inbound email as an event source is genuinely useful: ticket creation from support@ , magic-link replies, +tag routing, parsing supplier order confirmations, an ai@ address that hands a message to an agent. The classic answer is to point an MX record at a provider that parses the mail and POSTs you JSON. That works, but now a third party reads every message before you do, and you pay per inbound.
Storing email attachments in Cloudflare R2
If you are running email on Cloudflare, the bodies are easy: text and HTML are small, they live happily as columns in D1. Attachments are the part that bites you. A single thread can carry tens of megabytes of PDFs, images, and the occasional zip, and none of that belongs in a SQLite row. This is a walkthrough of doing attachment storage properly on Cloudflare: where the bytes go, how to key them, and how to serve them back without leaking your bucket to the world. We will build it by hand first so you understand every moving part, then show the version where you do not have to.
Using Cloudflare Queues to send email reliably at volume
You wrote a clean little route. A user does something, you send a confirmation email inline, you return 200. It works. Then a launch happens, a thousand signups land in a minute, and your logs fill with timeouts and dropped mail. Nothing about the email got harder; you just stopped being able to do it synchronously.
Cloudflare Email Routing tutorial: receive inbound mail in a Worker
The outbound half: why Email Routing can't send covered sending from the edge. This is the other half: receiving. Cloudflare Email Routing accepts mail at your domain and, instead of just forwarding it to Gmail, can hand each message to a Worker you control. That Worker is where inbound mail stops being a forwarded copy and becomes structured data you can query, search, and feed to an agent.
Set up a catch-all address with Cloudflare Email Routing
A catch-all address is one rule that matches every local part at a domain that doesn't already have an explicit rule. Instead of creating support@ , hello@ , billing@ , careers@ , and the dozen aliases you'll think of later, you set one wildcard and everything lands in the same place. Cloudflare Email Routing ships this as a first-class feature, and the basic version takes about five minutes. The interesting version, where the catch-all feeds a Worker and you keep the mail, takes a little longer. Here's both.
Send scheduled email digests with Cloudflare Cron Triggers
A digest email is deceptively simple to describe and annoying to run. The logic ("gather the last day's activity, format it, mail it") is trivial. The hard part is the recurring, reliable, time-zone-correct trigger , and a Worker has no built-in scheduler the way a Linux box has crontab. Cloudflare's answer is Cron Triggers, and they are good, but they behave differently from a unix cron in ways that will bite you if you assume otherwise.
Connect ChatGPT and other assistants to your inbox over MCP
To connect ChatGPT and other assistants to your email over MCP, expose your inbox as one MCP server and point every client at the same /mcp URL. ChatGPT, Cursor, and headless scripts authenticate with a scoped bearer token; the Claude app additionally supports one-click OAuth. The same typed tools (search, read, triage, send) work across every client because MCP is a shared protocol, not a per-vendor SDK. This walkthrough connects multiple assistants to one inbox, is honest about where the OAuth path stops and the bearer path takes over, and shows the hard way (building a multi-client MCP server) before the shortcut.
Build a newsletter signup with double opt-in on Cloudflare
Single opt-in is one INSERT: someone types an address, you store it, done. It is also how you end up mailing spam traps, typo'd addresses, and people who never asked, all of which quietly poison your sender reputation. Double opt-in adds one step: the address is only real once its owner clicks a confirmation link. That single extra hop is what keeps your list clean and your consent provable.
Your inbox is now an MCP server: connect Claude to your email
The reason AI assistants are bad at email isn't the models; it's access. Your mail lives behind a vendor's UI, and the assistant can't get to it without screen-scraping or a brittle integration. Tinbox flips this: because your inbox is a database you own , Tinbox can expose it as a proper MCP server , and any MCP-capable assistant can connect to it directly.
Why Node SMTP fails in Cloudflare Workers — and what works
You're building on Cloudflare Workers. Everything is fast and cheap and lives at the edge. Then you need to send one email (a password reset, an order receipt) and you reach for the thing you've used a hundred times:
How to build an MCP server on Cloudflare Workers
An MCP server on Cloudflare Workers is a stateless JSON-RPC 2.0 HTTP endpoint that answers three methods: initialize , tools/list , and tools/call . You do not need the official SDK or a persistent session. You parse each POST, switch on the method, and return a JSON-RPC envelope. That is the whole shape, and it maps cleanly onto the Fetch Request / Response a Worker already speaks.
BIMI setup: show your brand logo in the inbox
BIMI (Brand Indicators for Message Identification) is the standard that puts your logo in the inbox. When it works, a supporting mail client shows your brand mark next to your messages instead of a generic letter or a colored initial. It looks like a small thing. It is a real trust signal, and it is one of the few inbox affordances you can actually control as a sender.
AI inbox triage: automatically sort and prioritize your email
AI inbox triage is the practice of running a classifier over every inbound message and writing back structured conclusions: a category like promotions or support , a priority flag, and any extracted fields like an order number or a one-time code. The hard part is not the model call. It is doing it cheaply, deterministically where you can, and without your classifier silently regressing every time you tweak a prompt.
Build an AI email agent with typed tools over your own inbox
An AI email agent is a language model wired to a set of typed tools over your mail store, so it can take actions (search, read, summarize, draft, send) instead of only answering questions about email in the abstract. The difference from a chatbot is the tool loop: when you ask "what needs my attention?", a chatbot guesses from training data, while an agent calls a search_emails tool, gets real rows back from your inbox, and reasons over them.
AI draft email replies: have an agent prepare them, not send them
To get AI draft email replies without auto-sending, give the agent read tools and a create_draft tool, but no send tool. The model reads the thread, writes a reply, and saves it as a draft tied to that conversation. A human opens the draft, edits, and presses send. The safety property is structural, not a prompt instruction: an agent can only call tools it was given, so an agent with no send verb cannot deliver mail no matter what it decides or what an attacker writes into an incoming email.
AI schedule and snooze email: build send-later and snooze as agent tools
AI schedule and snooze email means an agent turns a natural-language request into durable state that a clock later acts on: a row that says "send this draft at timestamp T" or "hide this thread until timestamp W." The agent does not stay awake until then. It parses the time, writes the row, and returns. A scheduled job does the timed part. Get that division right and send-later and snooze are about 150 lines of infrastructure plus two small tool definitions.
Let an AI agent label and tag incoming email by intent
Labeling email by intent means assigning each inbound message one tag from a small fixed set, so your inbox can filter, route, and badge on it. The classification itself is the easy part. The work is doing it cheaply where the answer is obvious, reaching for a model only where intent is genuinely ambiguous, and writing the label back to your own store without standing up a separate tagging service.
Add transactional and lifecycle email to your SaaS in a day
"Add email to your SaaS" sounds like a one-liner: install an SDK, call send . The market is full of drop-ins that promise exactly that, and if you just want to survey them quickly, the tools to add email to your app in an afternoon is the shortlist. But the SDK is the easy part. Email in a real product is four jobs wearing a trench coat. There is the trigger (the user did a thing). There is the template (turn data into HTML). There is the suppression check (don't mail people who left or bounced). And there is delivery (sign it, relay it, track whether it landed). Transactional and lifecycle email are the same four jobs; only the trigger differs.
How to A/B test email subject lines on your own stack
Subject-line testing is the highest-leverage A/B test in email because the subject is the one thing every recipient sees before deciding whether to open. A two-point swing in open rate compounds across every campaign you send for the rest of the year. So it is worth doing properly. Once the plumbing here is in place it powers more than subject lines, so it is worth keeping a running list of email A/B tests worth running on your own stack to feed the same harness. The catch is that "properly" means two separate problems: the engineering of splitting a list and attributing events, which is easy, and the statistics of knowing when a difference is real, which is where most people, and most tools, quietly cut corners.
Send your first email with the tinbox/cf library
A deployed Tinbox is one Cloudflare Worker that, among everything else, exposes a Resend-style sending API at /api/send on your own account. This post is the narrow recipe: get a single transactional email out the door from a Worker, with the smallest amount of code that is still honest about what is happening.
Working with tinbox/cf: send, receive, and query your inbox in code
Tinbox runs as a single Cloudflare Worker. tinbox/cf is how that Worker is assembled, and today Cloudflare is the platform Tinbox targets — so this is simply how you build with Tinbox in code, not one library option among several. If you have not deployed yet, the npx tinbox init walkthrough stands the Worker up in two commands; this article is what you do once it is running. No invented endpoints — if it is here, it ships.
Local-first email development: run the whole app on SQLite before you deploy
Most "try it" flows for email infrastructure put the cloud account first. Sign up, create a database, add a domain, paste an API key, then maybe see a screen. For Cloudflare-targeted stacks that order is doubly awkward, because the runtime is the edge and the natural assumption is that you cannot run it anywhere else.
Deploy your Tinbox email stack from GitHub Actions
A Tinbox email stack is a single Cloudflare Worker plus its D1 database, R2 bucket, KV namespace, and queues. Deploying it is just wrangler deploy with the schema migrated first. That is easy to do once interactively. The problem is doing it repeatably: across a team, across environments, and (for an agency) across a dozen client tenants that each live on their own domain. GitHub Actions is the obvious place to put that, and the whole thing is more boring than it looks. Here is the complete setup, including the failure modes that trip people up.