Skip to content

0019. Production email through Cloudflare Email Service

  • Status: Accepted
  • Date: 2026-11-26
  • Deciders: Owner
  • Related: ADR 0003, ADR 0011, ADR 0014; openspec/changes/production-email/

Reviewer login used a console email sender. That is sufficient for local development but cannot deliver magic links in a hosted deployment. The hosted application runs on Cloudflare Workers and the account is on the Workers Paid plan. Cloudflare Email Service provides a native Worker binding, a REST API and SMTP for applications outside Workers, and includes 3,000 outbound emails per month before usage pricing. Email Sending is still in beta.

A separate provider such as Resend is generally available and has a mature API, but it adds another vendor, secret, and domain configuration. The project already depends on Cloudflare for the hosted runtime.

  • Use Cloudflare Email Service as the first production email provider behind the existing EmailSender port.
  • Use the keyless send_email Worker binding in apps/api. The binding is restricted to the configured sender address.
  • Use the Cloudflare Email Sending REST API in apps/api-node for self-host and other Node deployments. The API token is scoped to Email Sending: Edit and stored as a secret.
  • Share one magic-link message builder for subject, plain-text body, HTML body, application link, and expiry.
  • Keep the console sender for development and tests. Production never falls back to it.
  • Catch provider errors, non-2xx responses, and timeouts in the adapters; log only the provider, status, and error code; and keep the authentication response generic.
  • Document Workers Paid, domain onboarding, SPF/DKIM/DMARC, beta status, limits, token scope, and a test-message procedure.
  • No second email vendor at launch and lower cost at the expected magic-link volume.
  • The Worker does not hold an email API token.
  • Self-host production email requires a Cloudflare account on Workers Paid, an onboarded sending domain, and an API token. Operators who do not want that can use the console sender for development or wait for a future alternate provider.
  • Cloudflare Email Sending is beta. The adapter boundary keeps a future Resend, SMTP, or other provider replaceable without changing the core authentication flow.
  • Domain onboarding changes DNS and remains an owner-gated action.
  • The dynamic daily quota must be checked before launch and monitored during early use.
  • Resend: generally available and vendor-neutral, but adds a separate account, domain, API key, and billing relationship. Keep it as a future adapter if Cloudflare’s beta status becomes a problem.
  • SMTP for Node: Cloudflare provides authenticated SMTP, but it adds an SMTP client dependency. The REST API is simpler for the first Node adapter.
  • REST API in both runtimes: one transport, but it puts a powerful account-level API token in the Worker and adds a network hop. The native Worker binding is the better hosted path.
  • Console sender only: not viable for hosted reviewer login.

ADR 0017 is reserved by the hosted-deployment plan and ADR 0018 covers agent publishing.