Adapters
Cloudflare Email Sending
Configure the Cloudflare Email Sending REST API adapter.
Cloudflare Email Sending
@opencoredev/email-sdk/cloudflareOfficialPayload-testedLive account required
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
| Option | Type | Required | Notes |
|---|---|---|---|
apiToken | string | Yes | Cloudflare API token with Email Sending permission. |
accountId | string | Yes | Cloudflare account ID used in the Email Sending endpoint. |
baseUrl | string | No | Defaults to https://api.cloudflare.com/client/v4. |
fetch | typeof fetch | No | Useful 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.
