Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To send outbound email from a Cloudflare Worker, configure a send_email binding in Wrangler and call env.EMAIL.send(message). First onboard your domain for Cloudflare Email Service: Cloudflare says you must use Cloudflare DNS. This guide covers outbound sending, not inbound Email Routing.

Set up your domain for Cloudflare Email Service

In the Cloudflare dashboard, open the Email Sending area and onboard the domain you want to send from. Cloudflare’s setup guide requires Cloudflare DNS and describes adding the records for bounce routing, SPF, DKIM, and DMARC. Follow the records and values shown for your domain in the dashboard and guide: Cloudflare’s send-email setup guide.

Cloudflare says DNS changes can take up to 24 hours to propagate globally, though domains using Cloudflare DNS typically complete setup in 5–15 minutes. These are stated expectations, not a guarantee.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure the Worker binding

Add a send_email binding to the Wrangler configuration for the Worker. The binding name is the name you will use in code; this example exposes it as EMAIL. Wrangler also supports restrictions on which senders or recipients the binding can use. Apply those restrictions when the Worker should not be able to send to arbitrary addresses. See Cloudflare’s Workers API reference for the binding options and message shape.

Keep this email binding separate from the general Worker deployment configuration. Wrangler’s general configuration documentation lists name, main, and compatibility_date as required deployment settings; they are not substitutes for the email binding.

Send a message with env.EMAIL.send()

Declare the binding in the Worker environment type, then pass a structured message with a recipient, sender, subject, and text or HTML body. For example:

export interface Env {
  EMAIL: SendEmail;
}

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    try {
      const result = await env.EMAIL.send({
        to: "recipient@example.com",
        from: "welcome@yourdomain.com",
        subject: "Welcome",
        text: "Thanks for signing up.",
      });
      return Response.json({ success: true, messageId: result.messageId });
    } catch (error) {
      return new Response("Email send failed", { status: 500 });
    }
  },
};

Replace the example addresses with addresses appropriate to your configured domain. Confirm that your project’s generated TypeScript types include SendEmail for its compatibility setup and binding name. The API accepts an EmailMessage or EmailMessageBuilder, returns a promise, and documents returning a message ID and handling errors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Message formats, attachments, and limits

A structured message can include text or HTML content. Cloudflare’s Workers API reference documents attachments as base64-encoded content and sets these limits:

  • Recipients: up to 50 in the structured message.
  • Total message size: up to 5 MiB, including attachments.

These are limits stated in Cloudflare’s API documentation, not independent test results. Keep attachment encoding and the combined message size in mind when building the message.

Run and deploy the Worker, then check delivery

Cloudflare’s getting-started workflow uses npm create cloudflare@latest to create a project, adds a remote email binding, runs npx wrangler dev, and deploys using the project’s deploy script. Follow the commands and binding setup in the getting-started guide for the project scaffold you choose.

After sending, check the recipient’s inbox and spam folder. A successful API response is not proof that a message landed in the inbox: Cloudflare’s example response distinguishes delivered, permanently bounced, and queued recipients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How outbound sending differs from Email Routing

Use the Worker’s send_email binding and send() method to send outbound mail. Email Routing handles incoming mail: routing rules can direct a message to a verified destination or a Worker, where an email() handler can forward, reply to, reject, or process it. The inbound interface is not a general outbound-send API. See Cloudflare’s inbound email handler documentation and routing rules and addresses documentation.

There is a narrow destination-address exception: Cloudflare says a verified Email Routing destination can be sent to directly through the REST API or Workers binding, free of charge on any plan, even when only Email Routing is configured. Those sends do not count toward monthly quota or daily sending limits. This applies to verified destination addresses, not arbitrary recipients; a routing rule pointing to an unverified destination remains disabled. Details are in Cloudflare’s routing rules and addresses documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Which sending interface should you use?

Where the code runs Documented interface Use
Cloudflare Worker send_email binding and env.EMAIL.send() Native Worker code path for outbound messages.
Application outside Workers REST API or SMTP Interfaces Cloudflare documents for other applications.
Incoming mail routed to a Worker email() handler Inbound processing, not outbound sending.

Cloudflare documents these choices by execution context and interface; the documentation cited here does not establish a performance comparison among email providers.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.