Email
Cloudflare Email Service
Send email through Cloudflare, with a Worker binding or an API token.
cloudflareEmail() from tenoncms/email/cloudflare sends through Cloudflare Email Service. It needs no SMTP server and no extra package. It has two modes:
| Binding | API token | |
|---|---|---|
| Call | cloudflareEmail(env.EMAIL) | cloudflareEmail({ accountId, apiToken }) |
| Sends via | A send_email binding of your Worker | Cloudflare's REST API |
| Runs on | Cloudflare Workers only | Node, Vercel and Workers |
Before you start, onboard the domain of your sender to Email Service in the Cloudflare dashboard.
On the Workers Free plan, Email Service sends only to verified destination addresses. While invites, sign-in and similar will work with the free plan, you likely won't want to add every address as a verified destination and therefore would require the Workers Paid plan. This is regardless of mode. Last change: 2026-11-28
On Cloudflare (Worker)
- Add the binding to
wrangler.jsonc:wrangler.jsonc"send_email": [{ "name": "EMAIL" }], - Pass the binding to the adapter.
envcomes fromcloudflare:workers:tenon.config.tsimport { env } from "cloudflare:workers"; import { cloudflareEmail } from "tenoncms/email/cloudflare"; export default defineCms({ // ... email: { adapter: cloudflareEmail(env.EMAIL), from: "My Site <hello@example.com>", }, });
wrangler dev does not send mail through the binding. It logs each mail and saves it to a local file. To send real mail from wrangler dev, add "remote": true to the binding.
Anywhere else (API)
- Create an API token in the Cloudflare dashboard with the permission Email Sending Write.
- Set
CLOUDFLARE_ACCOUNT_IDandCLOUDFLARE_EMAIL_API_TOKEN. - Pass them to the adapter:tenon.config.ts
import { cloudflareEmail } from "tenoncms/email/cloudflare"; export default defineCms({ // ... email: { adapter: cloudflareEmail({ accountId: process.env.CLOUDFLARE_ACCOUNT_ID!, apiToken: process.env.CLOUDFLARE_EMAIL_API_TOKEN!, }), from: "My Site <hello@example.com>", }, });
Limits and errors
- A missing binding, account ID or token fails when Tenon sends, not at startup. A build without the variables still works.
- A failed send throws an
Errorwith acode. With the binding, it names the failure, likeE_SENDER_NOT_VERIFIED. With the API, it is Cloudflare's error number, like10208. - The API mode also throws when a recipient bounces for good. The other recipients can have the mail already, so do not send again blindly.
- Email Service also accepts SMTP. To use it that way, use
smtp()instead.
Related resources
- Email: send your own mail and change the built-in emails.
- Cloudflare: bindings for email, media and images on Workers.