Skill 02 · Cloudflare Email Service
Subchapter 2.1
references/cli-and-mcp.mdMarkdown4 KBView on GitHub
Manage Cloudflare Email Service from the command line and coding agents.
For full CLI reference, run npx wrangler email --help. For Dashboard setup, see the getting started docs.
wrangler email routing
├── enable/disable <domain> # Toggle email routing
├── dns get <domain> # Show required DNS records
├── rules list/create/update/delete # Manage routing rules
└── addresses list/create/delete # Destination addresses (account-scoped)
wrangler email sending
├── enable/disable <domain> # Toggle email sending
├── dns get <domain> # Show sending DNS records (SPF, DKIM)
├── send --from --to ... # Send an email (builder flags)
└── send-raw --from --to ... # Send a raw MIME emailThis auto-adds SPF (TXT) and DKIM (CNAME/TXT) records. DNS usually propagates within 5-15 minutes.
npx wrangler email sending enable yourdomain.com
npx wrangler email sending dns get yourdomain.com # Verify recordsAdd "remote": true to send real emails during wrangler dev:
{ "send_email": [{ "name": "EMAIL", "remote": true }] }npx wrangler devEmails are actually sent — use test addresses you control. Remove "remote": true before deploying.
If you have the Cloudflare MCP server (opens in a new tab) (https://mcp.cloudflare.com/mcp) configured, you can manage Email Service through its search and execute tools.
Use search to find email sending endpoints:
// search tool — find all email sending API endpoints
async () => {
const results = [];
for (const [path, methods] of Object.entries(spec.paths)) {
if (path.includes('email/sending')) {
for (const [method, op] of Object.entries(methods)) {
results.push({ method: method.toUpperCase(), path, summary: op.summary });
}
}
}
return results;
}Then use execute to call them — for example, checking sending limits or sending an email:
// execute tool — check sending quota
async () => {
return cloudflare.request({
method: "GET",
path: `/accounts/${accountId}/email/sending/limits`
});
}
// execute tool — send an email
async () => {
return cloudflare.request({
method: "POST",
path: `/accounts/${accountId}/email/sending/send`,
body: {
to: "user@example.com",
from: { address: "notifications@yourdomain.com", name: "My App" },
subject: "Deployment Complete",
html: "<h1>Deployed!</h1>",
text: "Deployed!"
}
});
}GraphQL analytics queries also work through execute — see deliverability.md for query examples. Note that email analytics are zone-level datasets (emailSendingAdaptiveGroups, emailSendingAdaptive) queried under viewer > zones, and require the Analytics Read token permission.
npx wrangler email sending send \
--from "agent@yourdomain.com" \
--to "developer@company.com" \
--subject "Deployment Complete" \
--text "Your Worker was deployed successfully."Or via REST API:
curl "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/email/sending/send" \
--header "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
--header "Content-Type: application/json" \
--data '{
"to": "developer@company.com",
"from": {"address": "agent@yourdomain.com", "name": "Build Agent"},
"subject": "Deployment Complete",
"text": "Your Worker was deployed successfully."
}'