Skip to main content

Email Routing

Learning Focus

By the end of this lesson you will understand how to set up free email forwarding with Cloudflare, configure catch-all addresses, create routing rules, and integrate with Email Workers.

What Is Cloudflare Email Routing?

Cloudflare Email Routing lets you create custom email addresses for your domain and forward them to any existing email inbox — completely free. You don't need to set up a mail server or pay for email hosting.

For example, you can create hello@yourdomain.com and have all emails forwarded to your personal Gmail or Outlook inbox.

flowchart LR
SENDER["Someone sends email to\nhello@yourdomain.com"] --> CF["Cloudflare\nEmail Routing"]
CF -->|Forward| DEST["your-real@gmail.com"]

CF -->|Or route to| WORKER["Email Worker\n(custom processing)"]
WORKER -->|Forward / Reply / Store| ACTION["Custom Action"]

style CF fill:#f6821f,color:#fff,stroke:#e5711e
style WORKER fill:#2563eb,color:#fff,stroke:#1e40af

Why Email Routing?

FeatureCloudflare Email RoutingTraditional Email Hosting
CostFree$3–$12/month per user
SetupMinutes (DNS auto-configured)Complex (mail server, SPF, DKIM, DMARC)
Custom addressesUnlimitedLimited by plan
Catch-all✅ FreeOften paid or absent
Sends mail?❌ (forwarding only)✅ Full send/receive
Workers integration✅ Free❌ Not available
Limitation

Email Routing is receive-and-forward only. You cannot send emails from your custom address through Cloudflare. To send as your custom address, configure "Send mail as" in your destination provider (Gmail, Outlook, etc.).

Setting Up Email Routing

Step 1: Enable Email Routing

  1. Go to Cloudflare Dashboard → Email → Email Routing
  2. Click "Get started"
  3. Cloudflare automatically configures the required DNS records:
┌────────────────────────────────────────────────────────────────────┐
│ Type Name Content TTL │
├────────────────────────────────────────────────────────────────────┤
│ MX yourdomain.com route1.mx.cloudflare.net Auto │
│ MX yourdomain.com route2.mx.cloudflare.net Auto │
│ MX yourdomain.com route3.mx.cloudflare.net Auto │
│ TXT yourdomain.com v=spf1 include:_spf... Auto │
└────────────────────────────────────────────────────────────────────┘

Step 2: Verify Your Destination Address

Before you can forward emails, you must verify the destination email address:

  1. Add your destination email (e.g., your-real@gmail.com)
  2. Cloudflare sends a verification email
  3. Click the verification link to confirm

Step 3: Create Routing Rules

Add custom addresses and their forwarding destinations:

Custom AddressForwards To
hello@yourdomain.comyour-real@gmail.com
support@yourdomain.comyour-real@gmail.com
billing@yourdomain.comfinance@company.com

Catch-All Address

A catch-all address captures any email sent to your domain that doesn't match a specific rule. This means anything@yourdomain.com will be forwarded to your destination address.

Enabling Catch-All

  1. Go to Email → Email Routing → Routing Rules
  2. Scroll to "Catch-all address"
  3. Set the action: Forward or Drop
  4. Specify the destination email address
flowchart TD
EMAIL["Incoming email to\nrandom@yourdomain.com"]
EMAIL --> CHECK{"Matches a\nspecific rule?"}
CHECK -->|Yes| RULE["Route to\nspecific destination"]
CHECK -->|No| CATCHALL{"Catch-all\nenabled?"}
CATCHALL -->|Yes| FORWARD["Forward to\ncatch-all destination"]
CATCHALL -->|No| DROP["Drop\n(no delivery)"]

style FORWARD fill:#16a34a,color:#fff,stroke:#15803d
style DROP fill:#dc2626,color:#fff,stroke:#b91c1c
Anti-Spam Tip

Catch-all addresses can attract spam. Consider using Drop for the catch-all and only creating specific rules for addresses you want to receive mail at.

Sending As Your Custom Address

Cloudflare Email Routing is receive-only, but you can send from your custom address through your email provider:

Gmail "Send mail as"

  1. In Gmail, go to Settings → Accounts → Send mail as → Add another email
  2. Enter your custom address (e.g., hello@yourdomain.com)
  3. Gmail will ask for an SMTP server — use your Gmail SMTP:
  4. Verify via the confirmation email
  5. You can now send emails that appear to come from hello@yourdomain.com
caution

When using Gmail's "Send mail as," the email headers will show via gmail.com. This is normal and does not affect deliverability for most purposes.

Email Workers Integration

For advanced use cases, you can route incoming emails to a Cloudflare Worker that processes them programmatically:

email-worker.js
export default {
async email(message, env, ctx) {
// Log the sender and subject
console.log(`From: ${message.from}`);
console.log(`To: ${message.to}`);
console.log(`Subject: ${message.headers.get("subject")}`);

// Forward to a specific address
await message.forward("your-real@gmail.com");

// Or conditionally route based on content
if (message.to === "support@yourdomain.com") {
await message.forward("support-team@company.com");
}
}
};

What Email Workers Can Do

ActionDescription
message.forward(to)Forward the email to another address
message.reply(response)Send an auto-reply
message.setReject(reason)Reject the email with a reason
message.headersRead email headers (subject, from, to, etc.)
message.rawAccess the raw email (for parsing attachments, etc.)

Use Cases for Email Workers

  • Auto-replies — Respond to support emails automatically
  • Filtering — Block spam based on sender, subject, or content patterns
  • Logging — Store email metadata in Workers KV or D1
  • Webhook integration — Forward email content to Slack, Discord, or a custom API

Common Misconceptions

"I need email hosting to use a custom email address"

Reality: For receiving email, Cloudflare Email Routing is completely free and sufficient. You only need paid email hosting if you need a full inbox with folders, calendars, and direct sending.

"Email Routing replaces Google Workspace or Office 365"

Reality: Email Routing is a forwarding service, not a replacement for full email hosting. If you need calendars, shared mailboxes, and enterprise features, you still need a dedicated email provider.

"Catch-all means I'll get spammed"

Reality: Catch-all can increase spam if bots discover valid addresses. Use specific routing rules instead of catch-all if spam is a concern, or use an Email Worker to filter incoming messages.

Key Takeaways

  • Cloudflare Email Routing is completely free — unlimited custom addresses with forwarding.
  • Catch-all captures emails to any address at your domain.
  • You can send as your custom address using Gmail's "Send mail as" feature.
  • Email Workers allow programmatic processing of incoming emails.
  • Email Routing is receive-only — it does not replace full email hosting.

What's Next

  • Continue to SSL and Encryption to learn how Cloudflare secures connections between visitors, edge, and origin.