Introduction¶
Adding transactional emails like “registration confirmation,” “password reset,” or “ticket notifications” to Cloudflare Workers or Agents applications typically involves integrating a third-party email service and wrestling with SPF, DKIM, delivery limits, and wrangler binding configurations. In 2025, Cloudflare integrated Email Sending and Email Routing directly into the platform. Sending can be done via Workers bindings or REST API, while receiving can be handled using the Worker’s email() handler. With rapid product iteration, details from model pre-training can easily become outdated.
Below is an introduction to the cloudflare-email-service Skill in Cloudflare’s official repository. It organizes prerequisite checks, scenario routing, reference documentation indexes, and common pitfalls into searchable guidance for Agents. It emphasizes “deferring to official documentation and type definitions” to reduce rework caused by incorrect wrangler configurations or API fields.
What is this¶
cloudflare-email-service is an Agent Skill maintained by Cloudflare in the cloudflare/skills repository, described as: “Implement or troubleshoot Cloudflare Email Sending, Email Routing, and their delivery configurations.”
It is designed for coding assistants (Cursor, Claude Code, Copilot, etc.) and human-in-the-loop development workflows. It prompts users to perform domain and binding checks before writing email-related code, then navigates to scenario-specific instructions under references/ for sending, routing, REST, CLI/MCP, and deliverability. It also explicitly states that in case of conflicts with other documentation, the Cloudflare docs, REST API spec, @cloudflare/workers-types, and Agents SDK documentation are the sources of truth.
Core Features¶
The Skill body organizes capabilities into a path table based on “what you want to do.” Verified capabilities include:
| Goal | Recommended Path |
|---|---|
| Send email in a Worker | send_email binding, no API key required |
| Send/Handle email in Agents SDK | Agent’s onEmail(), replyToEmail() |
| Send from external apps (Node.js, Go, Python, etc.) | Email Sending REST API (Bearer token) |
| Coding assistants managing domains & sending | wrangler CLI, MCP tools, or REST |
| Receive and process inbound email | Worker email() handler (Email Routing) |
| First-time enablement of sending or routing | wrangler email sending enable, wrangler email routing enable, or Dashboard |
| Reduce spam folder probability | SPF/DKIM/DMARC, content & compliance (see deliverability reference) |
The Skill also includes a Retrieval Sources table: for example, using the Cloudflare MCP docs tool or https://developers.cloudflare.com/email-service/index.md to check limits and pricing; REST specifications at https://developers.cloudflare.com/api/resources/email_sending/index.md; and types in @cloudflare/workers-types on npm.
The FIRST: Check Prerequisites three-step process before writing code is detailed in the materials:
- Is the domain onboarded for sending:
npx wrangler email sending list; if not listed, runnpx wrangler email sending enable userdomain.com. - Is the
send_emailbinding configured inwrangler.jsonc. - If parsing inbound MIME: is
postal-mimeinstalled (npm ls postal-mime).
The Common Mistakes table covers typical errors, such as forgetting the binding, sending from a domain that was never verified, reading message.raw twice, sending only HTML without text, treating transactional emails as marketing blasts, using email instead of address for from in REST, or using reply_to in REST when Workers uses replyTo.
Installation and Activation¶
In assistant environments that support Skills, the installation method provided by the official skills directory is:
npx skills add https://github.com/cloudflare/skills --skill cloudflare-email-service
You can also provide the Skill directory link to your assistant for installation:
https://github.com/cloudflare/skills/tree/main/skills/cloudflare-email-service
The Skill itself follows the universal SKILL.md format, accompanied by a map of scenario-specific documents such as references/sending.md, routing.md, rest-api.md, cli-and-mcp.md, and deliverability.md. Before implementation, you should read the corresponding reference as required by the Skill and cross-reference it with the project’s wrangler / SDK versions, rather than blindly upgrading dependencies.
The wrangler-side example for the sending domain (consistent with the materials and Cloudflare Workers API docs):
npx wrangler email sending list
npx wrangler email sending enable yourdomain.com
Worker bindings are written in wrangler.jsonc:
{
"send_email": [{ "name": "EMAIL" }]
}
After modifying bindings, both the Skill and official documentation suggest running wrangler types via the project’s package manager to use generated types rather than handwriting email interfaces.
Inbound routing can be configured via the Dashboard at Compute & AI → Email Service → Email Routing → Routing Rules, or by using wrangler email routing rules create. Forwarding targets must be verified first, for example via wrangler email routing addresses create user@gmail.com.
Typical Usage¶
1. Sending Transactional Email within a Worker¶
Provided the domain is onboarded and the binding is configured, send via env.EMAIL.send() (example from Email Sending Workers API):
const response = await env.EMAIL.send({
to: "recipient@example.com",
from: "welcome@yourdomain.com",
subject: "Welcome to our service!",
html: "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
text: "Welcome! Thanks for signing up.",
});
The from address must use a domain registered with Email Service. The Skill explicitly requires providing both html and text to accommodate plain-text clients and to improve spam scoring.
2. Inbound Email: Forwarding and Replying¶
A minimal email() handler from the Routing reference:
export default {
async email(message, env, ctx): Promise<void> {
console.log(`Email from ${message.from} to ${message.to}`);
await message.forward("team@company.com");
},
} satisfies ExportedHandler<Env>;
Forwarding addresses must be verified via the Dashboard or CLI beforehand. If replying directly within the Worker, it is recommended to use the same send_email binding (routing reference example):
async email(message, env, ctx) {
const subject = message.headers.get("subject") || "";
await env.EMAIL.send({
to: message.from,
from: message.to,
subject: `Re: ${subject}`,
html: "<p>Thanks! We'll respond shortly.</p>",
text: "Thanks! We'll respond shortly.",
});
await message.forward("team@company.com");
}
When parsing the body, you must buffer message.raw first (it can only be read once):
import PostalMime from "postal-mime";
const rawBuffer = await new Response(message.raw).arrayBuffer();
const parsed = await PostalMime.parse(rawBuffer);
3. External Applications and Assistant Operations¶
Non-Worker scenarios use the REST API (note the field naming differences compared to bindings; see Skill’s Common Mistakes). Coding assistants can also use wrangler and MCP tools for domain onboarding and troubleshooting according to references/cli-and-mcp.md.
Regarding sending strategy, the Skill’s Sending Workflow specifies: prefer bindings for Workers; consult rest-api.md only for external apps or when HTTP is explicitly requested by the user.
Use Cases and Considerations¶
Best for:
- Running Workers on Cloudflare and wanting to use native platform capabilities for transactional emails, avoiding keys and billing splits with an additional email vendor.
- Routing inbound emails for a domain to a Worker for forwarding, rejection, parsing, or a “store first, then reply by human or Agent” workflow (the routing reference includes patterns for storing messages in a Durable Object and replying later with
env.EMAIL.send). - Agents built with the Agents SDK that are triggered by email, requiring alignment with official walkthroughs for
onEmail()/replyToEmail().
Limitations and Notes (Sourced from Skill and official documentation):
- Email Service is designed for transactional emails and is not suitable for marketing blasts; use dedicated marketing platforms for large campaigns.
- Use real, controllable addresses for development testing; sending to non-existent addresses generates bounces and damages sender reputation.
- Do not write API tokens into source code; use environment variables or Cloudflare secrets.
- The Skill may lag behind product updates; if there are discrepancies, defer to Cloudflare documentation and API specs, and prioritize retrieval over relying on model memory.
- If the inbound handler neither consumes
rawnor callsforward/reject, the email is discarded; forwarding to an unverified address will fail.
Conclusion¶
cloudflare-email-service organizes the Email Sending / Routing capabilities that have been gradually forming in Cloudflare since 2025 into a workflow of “check prerequisites → select path → read references → avoid common errors.” It is particularly convenient for developers who are configuring send_email in Workers for the first time, distinguishing between REST and binding fields, or handling single-use message.raw.
Official Skill Directory: https://github.com/cloudflare/skills/tree/main/skills/cloudflare-email-service