Skip to content
GitHubXDiscord

EmailRouting

Enable and configure email routing for your Cloudflare zone to start receiving and routing emails sent to your domain.

Enable email routing for your domain:

import { EmailRouting } from "alchemy/cloudflare";
await EmailRouting("my-email-routing", {
zone: "example.com",
enabled: true,
});

Use an existing Zone resource reference:

import { EmailRouting, Zone } from "alchemy/cloudflare";
const zone = await Zone("my-zone", {
name: "example.com",
});
await EmailRouting("my-email-routing", {
zone: zone,
enabled: true,
skipWizard: true,
});

Configure email routing with specific settings:

import { EmailRouting } from "alchemy/cloudflare";
await EmailRouting("custom-email-routing", {
zone: "example.com",
enabled: true,
skipWizard: true, // Skip DNS setup wizard
});

Disable email routing when no longer needed:

import { EmailRouting } from "alchemy/cloudflare";
await EmailRouting("my-email-routing", {
zone: "example.com",
enabled: false,
});
  • zone (string | Zone): Zone ID or Zone resource where email routing will be configured
  • enabled (boolean, optional): Whether email routing should be enabled. Defaults to true
  • skipWizard (boolean, optional): Skip the DNS setup wizard when enabling email routing. Defaults to false
  • zoneId (string): Zone ID where email routing is configured
  • enabled (boolean): Whether email routing is enabled
  • name (string): Zone name
  • created (string): When email routing was created
  • modified (string): When email routing was last modified
  • tag (string): Zone tag

Before enabling email routing, ensure:

  1. You have a Cloudflare zone configured for your domain
  2. Your domain’s nameservers are pointed to Cloudflare
  3. You have the necessary DNS permissions for the zone

When email routing is enabled, Cloudflare automatically creates the necessary MX and TXT records for your domain. These records are required for email routing to function properly.

After enabling email routing:

  1. Create destination email addresses to receive forwarded emails
  2. Set up routing rules to define how emails are processed
  3. Configure a catch-all rule for unmatched emails