Email delivery
Commitment Desk sends reviewer magic links through email. Local development uses the console sender and needs no email account. Production uses Cloudflare Email Service.
Status and plan requirements
Section titled “Status and plan requirements”- Cloudflare Email Sending is in beta. Keep the adapter boundary in place so the provider can be replaced without changing authentication.
- Workers Paid is required to send to arbitrary reviewer addresses. The Workers Free plan only sends to verified destination addresses in the account.
- Workers Paid includes 3,000 outbound emails per month; additional email is $0.35 per 1,000.
- Email Sending is for transactional email only, not marketing or bulk campaigns.
Architecture
Section titled “Architecture”- Worker (
apps/api): uses the nativesend_emailbinding. The Worker does not need a Cloudflare API token. - Node/self-host (
apps/api-node): uses the Cloudflare Email Sending REST API with a Cloudflare API token scoped to Email Sending. - Shared content:
packages/api/src/email/magic-link-message.tsbuilds the subject, plain-text body, HTML body, application link, and expiry once for both transports. - Development and tests: the console sender prints the magic link and the route returns the development link outside production.
Production never falls back to the console sender. A missing Worker binding or sender configuration
produces a logged operational failure and the generic 202; a missing Node configuration fails the
Node server at startup.
Worker setup
Section titled “Worker setup”The production Worker configuration should contain:
{ "vars": { "ENVIRONMENT": "production", "EMAIL_FROM_NAME": "Commitment Desk", }, "send_email": [ { "name": "EMAIL", }, ],}Keep EMAIL_FROM aligned with allowed_sender_addresses. The Worker uses
env.EMAIL.send({ to, from: { email, name }, replyTo, subject, html, text }). Do not add a Cloudflare
API token to Worker code.
The checked-in local configuration uses "ENVIRONMENT": "development" and the same sender values.
For local development the console sender is used even when the binding is configured; the production
deployment must set ENVIRONMENT=production.
Node and self-host setup
Section titled “Node and self-host setup”Set the following environment variables for the Node adapter:
| Variable | Purpose |
|---|---|
EMAIL_PROVIDER |
cloudflare for production email; console for development |
CLOUDFLARE_ACCOUNT_ID |
Cloudflare account that owns the onboarded sending domain |
CLOUDFLARE_EMAIL_API_TOKEN |
API token with Email Sending: Edit; store as a secret |
EMAIL_FROM |
Sender address on the onboarded domain |
EMAIL_FROM_NAME |
Sender display name, default Commitment Desk |
EMAIL_REPLY_TO |
Optional reply-to address |
EMAIL_TIMEOUT_MS |
Provider timeout in milliseconds, default 5000 |
The REST adapter calls:
POST https://api.cloudflare.com/client/v4/accounts/{account_id}/email/sending/sendIt sends from.address, from.name, reply_to, the subject, text, and HTML. The API token is never
logged or exposed to the Worker.
Domain onboarding
Section titled “Domain onboarding”The sending domain must be onboarded into the Cloudflare account before the first production send. In the Cloudflare dashboard, go to Compute > Email Service > Email Sending and select Onboard Domain. Cloudflare adds:
- MX records on
cf-bounce.<domain>for bounce processing. - An SPF record on
cf-bounce.<domain>authorizing Cloudflare sending. - A DKIM record on
cf-bounce._domainkey.<domain>. - A DMARC record on
_dmarc.<domain>if the domain does not already have one.
DNS changes require owner approval. Existing SPF records must be merged, and existing DMARC records are left unchanged. Verify the records with:
dig MX cf-bounce.commitmentdesk.comdig TXT cf-bounce.commitmentdesk.comdig TXT cf-bounce._domainkey.commitmentdesk.comdig TXT _dmarc.commitmentdesk.comwrangler email sending list (beta) shows domains with Email Sending enabled:
pnpm --filter @commitment-desk/api exec wrangler email sending listcommitmentdesk.com must appear before production sending.
Limits
Section titled “Limits”- 50 recipients combined across to, cc, and bcc.
- 25 MiB total message size, including attachments.
- 16 KB custom headers.
- Daily sending quota is dynamic and scales with account reputation. Check it with:
curl "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/email/sending/limits" \ --header "Authorization: Bearer $CLOUDFLARE_EMAIL_API_TOKEN"If the quota is too low for launch, use Cloudflare’s limit-increase request form. Magic-link volume is expected to be low, but monitor the limit during demos and early onboarding.
Failure behavior
Section titled “Failure behavior”Magic-link delivery failures do not reveal whether an email belongs to an account:
- The API still returns HTTP
202. - The adapter logs the provider status and numeric error code only.
- The magic-link URL, raw token, API token, and full provider response are never logged.
- Use Cloudflare Email Service analytics and logs to investigate delivery failures.
Provider errors and timeouts are retried only when the provider indicates a transient failure. The current adapter does not add an application-level retry queue; the next login request can retry.
Local development and testing
Section titled “Local development and testing”Local development uses the console sender. Request a magic link from the login screen and use the development link printed by the API or shown on the page. No Cloudflare account is needed locally.
Tests use a fake Worker binding and a fake fetch implementation for the REST adapter. They assert
the message content, sender, reply-to, provider errors, timeouts, and redaction. No test sends real
email.
Self-host notes
Section titled “Self-host notes”Self-host operators who need production email need a Cloudflare account on Workers Paid, an onboarded
sending domain, and an API token with Email Sending: Edit. The console sender remains the
development default. A future SMTP or alternate-provider adapter can be added behind the existing
EmailSender port without changing the core or the Node configuration model.
Related
Section titled “Related”- ADR 0019 — Cloudflare provider and adapter boundary
- Self-hosting — Node environment and deployment notes
- Data handling — email addresses, tokens, and logging
- Cloudflare Email Service limits
- Cloudflare Email Service pricing