Email SDK
Adapters

Cloudflare Email Sending

Configure the Cloudflare Email Sending REST API adapter.

Cloudflare Email Sending logo
Cloudflare Email Sending
@opencoredev/email-sdk/cloudflare
OfficialPayload-testedLive account required
Open website
import { createEmailClient } from "@opencoredev/email-sdk";
import { cloudflare } from "@opencoredev/email-sdk/cloudflare";

const email = createEmailClient({
  adapters: [
    cloudflare({
      apiToken: process.env.CLOUDFLARE_API_TOKEN!,
      accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
    }),
  ],
});

Options

OptionTypeRequiredNotes
apiTokenstringYesCloudflare API token with Email Sending permission.
accountIdstringYesCloudflare account ID used in the Email Sending endpoint.
baseUrlstringNoDefaults to https://api.cloudflare.com/client/v4.
fetchtypeof fetchNoUseful for tests or custom runtimes.

CLI

npx --yes --package @opencoredev/email-sdk email-sdk send \
  --adapter cloudflare \
  --api-token "$CLOUDFLARE_API_TOKEN" \
  --account-id "$CLOUDFLARE_ACCOUNT_ID" \
  --from "hello@example.com" \
  --to "user@example.com" \
  --subject "Hello" \
  --text "It works"

Cloudflare Email Sending requires a Cloudflare DNS domain onboarded to Email Service. New accounts may be limited to verified recipient addresses, and Email Sending is available on Workers Paid plans.

Cloudflare's REST API accepts to, cc, and bcc as plain email-address strings. The adapter preserves display names for from and replyTo, and rejects named recipients before the request instead of silently dropping the names.

See field support for supported message fields.

On this page