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:

BindingAPI token
CallcloudflareEmail(env.EMAIL)cloudflareEmail({ accountId, apiToken })
Sends viaA send_email binding of your WorkerCloudflare's REST API
Runs onCloudflare Workers onlyNode, 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)

  1. Add the binding to wrangler.jsonc:
    wrangler.jsonc
    "send_email": [{ "name": "EMAIL" }],
    
  2. Pass the binding to the adapter. env comes from cloudflare:workers:
    tenon.config.ts
    import { 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)

  1. Create an API token in the Cloudflare dashboard with the permission Email Sending Write.
  2. Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_EMAIL_API_TOKEN.
  3. 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 Error with a code. With the binding, it names the failure, like E_SENDER_NOT_VERIFIED. With the API, it is Cloudflare's error number, like 10208.
  • 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.
  • Email: send your own mail and change the built-in emails.
  • Cloudflare: bindings for email, media and images on Workers.