know.2nth.aiTechnologytechcloudflareEmail
Technology · Cloudflare · Skill Node

Cloudflare
Email.

Inbound email routing to Workers plus outbound sending via MailChannels. Process incoming mail with code and send transactional email from the same network — no separate email service needed for basic flows.

TechnologyEmail RoutingOpen TierLast updated · Apr 2026

Email as a programmable edge primitive.

Email Routing intercepts inbound email at Cloudflare's edge and routes it to a Worker for processing. Your Worker receives the raw email (headers, body, attachments) and can parse it, store it in R2, write to D1, trigger a Queue, or forward it to another address.

For outbound email, Cloudflare partnered with MailChannels to allow Workers to send transactional email without managing SMTP infrastructure. You make an HTTP POST from your Worker to MailChannels' API with your domain's SPF/DKIM configured to authorise Cloudflare.

This isn't a replacement for SendGrid or Postmark at scale. It's the right answer for "I have a domain on Cloudflare and I need to receive contact form submissions and send confirmation emails without adding another service."

Inbound routing and outbound sending.

01

Inbound: email() handler

A Worker with an email() handler receives inbound messages. Parse headers, extract the body, and route the content wherever it needs to go.

export default {
  async email(message, env, ctx) {
    const from = message.from;
    const subject = message.headers.get("subject");

    // Store in D1
    await env.DB.prepare(
      "INSERT INTO inbox (sender, subject) VALUES (?, ?)"
    ).bind(from, subject).run();

    // Forward to a real mailbox
    await message.forward("[email protected]");
  }
};
02

Outbound: MailChannels send

Send transactional email from a Worker by POSTing to the MailChannels API. Configure SPF and DKIM on your domain to authorise sending.

// Send email via MailChannels
const resp = await fetch("https://api.mailchannels.net/tx/v1/send", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    personalizations: [{ to: [{ email: "[email protected]" }] }],
    from: { email: "[email protected]", name: "Your App" },
    subject: "Welcome",
    content: [{ type: "text/plain", value: "Thanks for signing up." }],
  }),
});

Where it bites you.

MailChannels

Free MailChannels integration ended in 2024

Cloudflare's free MailChannels partnership has changed. Check current docs for the latest outbound sending options — you may need MailChannels' paid tier or an alternative like Resend.

Deliverability

SPF, DKIM, and DMARC are your problem

Cloudflare handles routing; you handle deliverability. Misconfigured DNS records mean your emails land in spam.

Attachment size

Email handler has Worker memory limits

Large attachments consume Worker memory. For emails with large files, forward to a real mailbox or stream attachments to R2.

When it fits. When it doesn't.

✓ Use it when
  • You want programmable inbound email. Parse incoming messages, extract data, trigger workflows — without running a mail server.
  • Simple transactional email from Workers. Welcome emails, password resets, notifications from the same deploy surface.
  • Your domain is already on Cloudflare. Email Routing is free and configurable in the dashboard.

Where this node connects.

Go deeper.