Token导航 LogoToken导航

Agent Skill · 前端设计

cloudflare-email-routing(cloudflare 电子邮件路由)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

cloudflare-email-routing 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,第三方扫描有未通过项,按安装量在前端设计类的 10,216 个 Skill 里排第 4,526。

总安装 864周安装 36GitHub Stars 14下载 288核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:cloudflare-email-routing(cloudflare 电子邮件路由)
来源仓库:https://github.com/jackspace/claudeskillz
仓库路径:skills/cloudflare-email-routing
安装命令:
npx skills add https://github.com/jackspace/claudeskillz --skill cloudflare-email-routing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/jackspace/claudeskillz --skill cloudflare-email-routing

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

cloudflare-email-routing 提供邮件接收和处理的自定义逻辑能力。支持 allowlist/blocklist 过滤、转发和解析回复功能。集成 Email Workers 与 Send Email 服务构建完整邮件解决方案。所有功能免费,适用于通知提醒和自动化消息发送场景。

适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/cloudflare-email-routing

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/jackspace/claudeskillz --skill cloudflare-emai…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

cloudflare-email-routing 怎么安装?

在终端执行 npx skills add https://github.com/jackspace/claudeskillz --skill cloudflare-email-routing。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

cloudflare-email-routing 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

cloudflare-email-routing 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

cloudflare-email-routing 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

cloudflare-email-routing 用的人多吗?

公开数据是累计安装 864 次,近一周安装 36 次,下载 288 次,GitHub 14 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

cloudflare-email-routing 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
cloudflare-email-routing

cloudflare 电子邮件路由 · 本页

86414需要联网MIT未通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Cloudflare Email Routing

Status: Production Ready ✅ Last Updated: 2025-10-23 Latest Versions: postal-mime@2.5.0, mimetext@3.0.27


What is Cloudflare Email Routing?

Cloudflare Email Routing provides two complementary capabilities:

  1. Email Workers - Receive and process incoming emails with custom logic (allowlists, blocklists, forwarding, parsing, replying)
  2. Send Email - Send emails from Workers to verified destination addresses (notifications, alerts, confirmations)

Both capabilities are free and work together to enable complete email functionality in Cloudflare Workers.


Quick Start (10 Minutes)

Part 1: Enable Email Routing (Dashboard)

Prerequisites: Domain must be on Cloudflare DNS

  1. Log in to Cloudflare Dashboard → select your domain
  2. Go to Email > Email Routing
  3. Select Enable Email Routing → Add records and enable

- This automatically adds MX records, SPF, and DKIM to your DNS

  1. Create a destination address:

- Custom address: hello@yourdomain.com - Destination: Your personal email (e.g., you@gmail.com) - Verify the destination address via email

  1. ✅ Basic email forwarding is now active

What you just did: Configured DNS and basic forwarding. Now let's add Workers for custom logic.


Part 2: Receiving Emails with Email Workers

1. Install Dependencies
npm install postal-mime@2.5.0 mimetext@3.0.27

Why these packages:

  • postal-mime - Parse incoming email messages (headers, body, attachments)
  • mimetext - Create email messages for sending/replying
2. Create Email Worker

Create src/email.ts:

import { EmailMessage } from 'cloudflare:email';
import PostalMime from 'postal-mime';

export default {
  async email(message, env, ctx) {
    // Parse the incoming message
    const parser = new PostalMime.default();
    const email = await parser.parse(await new Response(message.raw).arrayBuffer());

    console.log('From:', message.from);
    console.log('To:', message.to);
    console.log('Subject:', email.subject);

    // Forward to verified destination
    await message.forward('your-email@example.com');
  },
};
3. Configure Wrangler

Update wrangler.jsonc:

{
  "name": "email-worker",
  "main": "src/email.ts",
  "compatibility_date": "2025-10-11"
}
4. Deploy and Bind
npx wrangler deploy

# In Cloudflare Dashboard:
# Email > Email Routing > Email Workers
# Select your worker → Create route → Enter address (e.g., hello@yourdomain.com)

What you just did: Created a Worker that logs and forwards emails.


Part 3: Sending Emails from Workers

1. Configure Send Email Binding

Update wrangler.jsonc:

{
  "name": "my-worker",
  "main": "src/index.ts",
  "compatibility_date": "2025-10-11",
  "send_email": [
    {
      "name": "EMAIL",
      "destination_address": "notifications@yourdomain.com"
    }
  ]
}

CRITICAL: destination_address must be:

  • A domain where you have Email Routing enabled
  • A verified destination address in Email Routing settings
2. Send Email from Worker
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

export default {
  async fetch(request, env, ctx) {
    // Create email message
    const msg = createMimeMessage();
    msg.setSender({ name: 'My App', addr: 'noreply@yourdomain.com' });
    msg.setRecipient('user@example.com');
    msg.setSubject('Welcome to My App');
    msg.addMessage({
      contentType: 'text/plain',
      data: 'Thank you for signing up!',
    });

    // Send via binding
    const message = new EmailMessage(
      'noreply@yourdomain.com',
      'user@example.com',
      msg.asRaw()
    );

    await env.EMAIL.send(message);

    return new Response('Email sent!');
  },
};
3. Deploy
npx wrangler deploy

What you just did: Configured your Worker to send emails to verified addresses.


Email Workers: Complete Guide

Runtime API

EmailEvent Handler
export default {
  async email(message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) {
    // Process email here
  },
};

Parameters:

  • message - ForwardableEmailMessage object
  • env - Environment bindings (KV, D1, secrets, etc.)
  • ctx - Execution context (waitUntil for async operations)
ForwardableEmailMessage Properties
interface ForwardableEmailMessage {
  readonly from: string;          // Sender email
  readonly to: string;            // Recipient email
  readonly headers: Headers;      // Email headers
  readonly raw: ReadableStream;   // Raw email message
  readonly rawSize: number;       // Size in bytes

  // Methods
  setReject(reason: string): void;
  forward(rcptTo: string, headers?: Headers): Promise<void>;
  reply(message: EmailMessage): Promise<void>;
}

Common Patterns

Pattern 1: Allowlist

Only accept emails from approved senders:

export default {
  async email(message, env, ctx) {
    const allowList = [
      'friend@example.com',
      'coworker@company.com',
      'support@vendor.com',
    ];

    if (!allowList.includes(message.from)) {
      message.setReject('Address not on allowlist');
      return;
    }

    await message.forward('inbox@yourdomain.com');
  },
};

When to use: Contact forms, private email addresses, team inboxes


Pattern 2: Blocklist

Reject emails from specific senders or domains:

export default {
  async email(message, env, ctx) {
    const blockList = [
      'spam@badactor.com',
      '@suspicious-domain.com', // Block entire domain
    ];

    const isBlocked = blockList.some(pattern =>
      message.from.includes(pattern)
    );

    if (isBlocked) {
      message.setReject('Sender blocked');
      return;
    }

    await message.forward('inbox@yourdomain.com');
  },
};

When to use: Spam filtering, blocking harassers, domain-level blocks


Pattern 3: Parse and Store

Extract email content and store in D1 or KV:

import PostalMime from 'postal-mime';

export default {
  async email(message, env, ctx) {
    // Parse email
    const parser = new PostalMime.default();
    const rawEmail = new Response(message.raw);
    const email = await parser.parse(await rawEmail.arrayBuffer());

    // Store in D1
    await env.DB.prepare(
      'INSERT INTO emails (from_addr, subject, text, received_at) VALUES (?, ?, ?, ?)'
    ).bind(
      message.from,
      email.subject,
      email.text,
      new Date().toISOString()
    ).run();

    // Forward to inbox
    await message.forward('inbox@yourdomain.com');
  },
};

When to use: Email archiving, ticket systems, support inboxes, audit logs


Pattern 4: Auto-Reply

Send automatic replies with custom logic:

import PostalMime from 'postal-mime';
import { createMimeMessage } from 'mimetext';
import { EmailMessage } from 'cloudflare:email';

export default {
  async email(message, env, ctx) {
    // Parse incoming email
    const parser = new PostalMime.default();
    const email = await parser.parse(await new Response(message.raw).arrayBuffer());

    // Create reply
    const msg = createMimeMessage();
    msg.setSender({ name: 'Support Team', addr: 'support@yourdomain.com' });
    msg.setRecipient(message.from);
    msg.setHeader('In-Reply-To', message.headers.get('Message-ID'));
    msg.setSubject(`Re: ${email.subject}`);
    msg.addMessage({
      contentType: 'text/plain',
      data: `Thank you for your message about "${email.subject}". We'll respond within 24 hours.`,
    });

    // Send reply
    const replyMessage = new EmailMessage(
      'support@yourdomain.com',
      message.from,
      msg.asRaw()
    );

    await message.reply(replyMessage);

    // Also forward to team inbox
    await message.forward('team@yourdomain.com');
  },
};

When to use: Out-of-office replies, support ticket acknowledgments, automated responses


Pattern 5: Conditional Routing

Route emails to different destinations based on content:

import PostalMime from 'postal-mime';

export default {
  async email(message, env, ctx) {
    const parser = new PostalMime.default();
    const email = await parser.parse(await new Response(message.raw).arrayBuffer());

    const subject = email.subject.toLowerCase();

    // Route based on subject keywords
    if (subject.includes('urgent') || subject.includes('critical')) {
      await message.forward('oncall@yourdomain.com');
    } else if (subject.includes('invoice') || subject.includes('payment')) {
      await message.forward('billing@yourdomain.com');
    } else if (subject.includes('support') || subject.includes('help')) {
      await message.forward('support@yourdomain.com');
    } else {
      await message.forward('inbox@yourdomain.com');
    }
  },
};

When to use: Department routing, priority filtering, category-based inboxes


Send Email: Complete Guide

Configuration

Single Destination (Simple)
{
  "send_email": [
    {
      "name": "EMAIL",
      "destination_address": "notifications@yourdomain.com"
    }
  ]
}

Behavior: All emails sent via env.EMAIL go to this address.

Multiple Destinations (Flexible)
{
  "send_email": [
    {
      "name": "EMAIL",
      "allowed_destination_addresses": [
        "notifications@yourdomain.com",
        "alerts@yourdomain.com",
        "user@gmail.com"
      ]
    }
  ]
}

Behavior: Can send to any address in the list.

Multiple Bindings (Organized)
{
  "send_email": [
    {
      "name": "NOTIFICATIONS",
      "destination_address": "notifications@yourdomain.com"
    },
    {
      "name": "ALERTS",
      "destination_address": "alerts@yourdomain.com"
    }
  ]
}

Behavior: Use different bindings for different purposes.


Sending Emails

Basic Text Email
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

const msg = createMimeMessage();
msg.setSender({ name: 'My App', addr: 'noreply@yourdomain.com' });
msg.setRecipient('user@example.com');
msg.setSubject('Welcome!');
msg.addMessage({
  contentType: 'text/plain',
  data: 'Welcome to our service!',
});

const email = new EmailMessage(
  'noreply@yourdomain.com',
  'user@example.com',
  msg.asRaw()
);

await env.EMAIL.send(email);
HTML Email
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

const msg = createMimeMessage();
msg.setSender({ name: 'My App', addr: 'noreply@yourdomain.com' });
msg.setRecipient('user@example.com');
msg.setSubject('Welcome!');

// Add both plain text and HTML versions
msg.addMessage({
  contentType: 'text/plain',
  data: 'Welcome to our service!',
});

msg.addMessage({
  contentType: 'text/html',
  data: '<h1>Welcome!</h1><p>Thanks for joining us.</p>',
});

const email = new EmailMessage(
  'noreply@yourdomain.com',
  'user@example.com',
  msg.asRaw()
);

await env.EMAIL.send(email);
Email with Custom Headers
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

const msg = createMimeMessage();
msg.setSender({ name: 'My App', addr: 'noreply@yourdomain.com' });
msg.setRecipient('user@example.com');
msg.setSubject('Password Reset');

// Add custom headers
msg.setHeader('X-Priority', '1');
msg.setHeader('X-Application-ID', 'my-app-123');

msg.addMessage({
  contentType: 'text/plain',
  data: 'Click here to reset your password...',
});

const email = new EmailMessage(
  'noreply@yourdomain.com',
  'user@example.com',
  msg.asRaw()
);

await env.EMAIL.send(email);

DNS Configuration

Automatic Setup (Recommended)

When you enable Email Routing in the dashboard, Cloudflare automatically adds:

  1. MX Records - Direct email to Cloudflare's servers yourdomain.com. 300 IN MX 13 amir.mx.cloudflare.net. yourdomain.com. 300 IN MX 86 linda.mx.cloudflare.net. yourdomain.com. 300 IN MX 24 isaac.mx.cloudflare.net.
  2. SPF Record - Authorize Cloudflare to send on your behalf yourdomain.com. 300 IN TXT "v=spf1 include:_spf.mx.cloudflare.net ~all"
  3. DKIM Records - Sign outgoing emails Automatically configured per domain

Manual Setup (Advanced)

If you need to migrate from another provider:

  1. Go to Email > Email Routing > Settings
  2. Select Start disabling > Unlock records and continue
  3. Edit DNS records as needed
  4. When ready, Lock DNS records to protect Email Routing

WARNING: Changing MX records will break Email Routing. Only do this if migrating providers.


Known Issues Prevention

This skill prevents 8 documented issues:

Issue #1: "Email Trigger not available to this workers"

Error: Testing email workers fails with "Email Trigger not available to this workers"

Source: workers-sdk #3751

Why It Happens: Wrangler dev doesn't fully support email triggers; testing must be done via deployed Workers

Prevention:

  • Always deploy email workers before testing
  • Use wrangler tail for live debugging
  • Use dashboard "Test Email Event" feature (when working)

Issue #2: Destination Address Verification Bug

Error: Verified destination addresses show as "unverified" in Email Worker forwarding

Source: Community reports (Cloudflare Community)

Why It Happens: Bug in dashboard where addresses only show verified if also used in regular routing rules

Prevention:

  • Create a regular forward rule for each destination address first
  • Then use the same addresses in Email Workers
  • Verify addresses before deploying workers

Issue #3: Gmail Rate Limiting

Error: "421: Our system has detected an unusual rate of unsolicited mail originating from your IP address"

Source: Community reports

Why It Happens: Gmail may flag Cloudflare's IP ranges as suspicious due to shared infrastructure

Prevention:

  • Implement proper SPF/DKIM/DMARC records
  • Don't send bulk emails through Email Routing
  • Use transactional email services (e.g., SendGrid, Mailgun) for high volume
  • Rate-limit your sending (max 50-100 emails/hour for personal use)

Issue #4: SPF Permerror with MailChannels

Error: SPF permerror when routing through MailChannels

Source: Community discussion

Why It Happens: SPF record chain breaks when forwarding through multiple services

Prevention:

  • Use Email Routing's native send capabilities instead of MailChannels
  • If using MailChannels, configure SPF includes correctly
  • Test with MXToolbox SPF checker

Issue #5: Limited Logging on Free Plan

Error: Cannot see worker logs or email processing details

Source: Community reports

Why It Happens: Free plan has limited log retention and streaming

Prevention:

  • Use wrangler tail during development for live logs
  • Use console.log() extensively in email workers
  • Store critical data in D1/KV for debugging
  • Upgrade to Workers Paid plan for better observability

Issue #6: Activity Log Discrepancies

Error: Emails show as "Dropped" in Activity Log even when successfully forwarded

Source: Community reports

Why It Happens: Dashboard bug showing incorrect status

Prevention:

  • Check actual email delivery instead of relying on dashboard
  • Use wrangler tail to verify processing
  • Implement your own logging in D1/KV
  • Test with real emails to confirm delivery

Issue #7: Test Email Event Loading Indefinitely

Error: Dashboard "Test Email Event" button remains in loading state forever

Source: workers-sdk #9195

Why It Happens: Bug in dashboard testing interface (unresolved as of 2025-10)

Prevention:

  • Don't rely on dashboard testing feature
  • Use curl with local development instead (see Local Development section)
  • Deploy and test with real emails
  • Use wrangler tail to monitor processing

Issue #8: Worker Call Failures

Error: "Rejected reason: Unknown error: failed to call worker: Worker call failed for 3 times, aborting…"

Source: workers-sdk #9069, Community reports

Why It Happens: Worker crashes due to runtime errors, timeouts, or memory issues

Prevention:

  • Add comprehensive error handling with try/catch
  • Set timeouts for external API calls
  • Log errors to D1/KV before rejecting
  • Use ctx.waitUntil() for non-critical operations
  • Test with various email formats (plain text, HTML, attachments)

Local Development

Receiving Emails

Wrangler simulates email reception via HTTP POST:

# Start dev server
npx wrangler dev

# In another terminal, send test email
curl http://localhost:8787 -X POST \
  --data-binary @- << EOF
From: sender@example.com
To: recipient@yourdomain.com
Subject: Test Email

This is a test email body.
EOF

What happens: Wrangler logs the email processing and shows where forwarded emails would go.

Sending Emails

Wrangler writes sent emails to local.eml files:

// Your worker code
await env.EMAIL.send(message);

Output in terminal:

[wrangler:inf] send_email binding called with the following message:
  /tmp/miniflare-abc123/files/email/message-123.eml

View the email:

cat /tmp/miniflare-abc123/files/email/message-123.eml

Configuration Files Reference

Complete wrangler.jsonc (Both Receive + Send)

{
  "$schema": "node_modules/wrangler/config-schema.json",
  "name": "email-worker",
  "main": "src/email.ts",
  "account_id": "YOUR_ACCOUNT_ID",
  "compatibility_date": "2025-10-11",
  "observability": {
    "enabled": true
  },

  // Send email binding
  "send_email": [
    {
      "name": "NOTIFICATIONS",
      "destination_address": "notifications@yourdomain.com"
    },
    {
      "name": "ALERTS",
      "allowed_destination_addresses": [
        "alerts@yourdomain.com",
        "admin@yourdomain.com"
      ]
    }
  ],

  // Optional: Add other bindings
  "d1_databases": [
    {
      "binding": "DB",
      "database_name": "email-archive",
      "database_id": "YOUR_DATABASE_ID"
    }
  ],

  "kv_namespaces": [
    {
      "binding": "EMAIL_CACHE",
      "id": "YOUR_KV_ID"
    }
  ]
}

TypeScript Types

Environment Bindings

interface Env {
  // Send email bindings
  EMAIL: SendEmail;
  NOTIFICATIONS: SendEmail;
  ALERTS: SendEmail;

  // Other bindings
  DB: D1Database;
  EMAIL_CACHE: KVNamespace;
}

interface SendEmail {
  send(message: EmailMessage): Promise<void>;
}

Full Type Definitions

import { EmailMessage } from 'cloudflare:email';

interface ForwardableEmailMessage {
  readonly from: string;
  readonly to: string;
  readonly headers: Headers;
  readonly raw: ReadableStream;
  readonly rawSize: number;

  setReject(reason: string): void;
  forward(rcptTo: string, headers?: Headers): Promise<void>;
  reply(message: EmailMessage): Promise<void>;
}

declare module 'cloudflare:email' {
  export class EmailMessage {
    constructor(from: string, to: string, raw: string | ReadableStream);
  }
}

Complete Setup Checklist

Email Routing Setup

  • Domain is on Cloudflare DNS
  • Email Routing enabled in dashboard
  • MX, SPF, DKIM records automatically added
  • At least one destination address verified
  • Test basic forwarding with a custom address

Email Workers (Receiving)

  • postal-mime@2.5.0 installed
  • mimetext@3.0.27 installed
  • Email worker created with async email() handler
  • Worker deployed: npx wrangler deploy
  • Worker bound to email route in dashboard
  • Test with real email to route address
  • Verify logs with wrangler tail

Send Email (Sending)

  • send_email binding configured in wrangler.jsonc
  • destination_address or allowed_destination_addresses specified
  • All destination addresses verified in Email Routing
  • Worker code uses env.EMAIL.send()
  • Worker deployed: npx wrangler deploy
  • Test sending email via Worker endpoint
  • Confirm email delivery to recipient

Troubleshooting

Problem: "Email Trigger not available to this workers"

Solution:

  • Deploy your worker: npx wrangler deploy
  • Test with real emails, not local simulation
  • Use wrangler tail to monitor processing

Problem: "Destination address not verified"

Solution:

  • Check Email Routing > Destination addresses in dashboard
  • Click "Resend verification" if needed
  • Create a regular forwarding rule first (workaround for bug)
  • Verify all addresses before deploying workers

Problem: Gmail rejects emails with 421 error

Solution:

  • Verify SPF/DKIM records are configured (automatic with Email Routing)
  • Reduce sending rate (max 50-100/hour for personal use)
  • Don't send unsolicited emails or bulk mail
  • Consider transactional email service for high volume

Problem: Emails not forwarding from Email Worker

Solution:

  • Check worker is bound to correct email route in dashboard
  • Verify destination address is verified
  • Use wrangler tail to see processing logs
  • Check for errors in worker code (try/catch around forward())
  • Confirm MX records are still pointing to Cloudflare

Problem: Cannot see worker logs

Solution:

  • Use wrangler tail --format pretty for live logs
  • Add extensive console.log() statements in worker
  • Store debug info in D1 or KV for later inspection
  • Upgrade to Workers Paid plan for better log retention

Problem: Worker crashes with "failed to call worker"

Solution:

  • Add try/catch error handling around all operations
  • Set timeouts for external API calls
  • Test with different email formats (plain text, HTML, attachments)
  • Check worker doesn't exceed CPU/memory limits
  • Use ctx.waitUntil() for non-blocking operations

Advanced Topics

Parsing Email Attachments

import PostalMime from 'postal-mime';

export default {
  async email(message, env, ctx) {
    const parser = new PostalMime.default();
    const email = await parser.parse(await new Response(message.raw).arrayBuffer());

    // Access attachments
    if (email.attachments && email.attachments.length > 0) {
      for (const attachment of email.attachments) {
        console.log('Attachment:', attachment.filename);
        console.log('Type:', attachment.mimeType);
        console.log('Size:', attachment.content.length);

        // Store in R2
        await env.BUCKET.put(
          `emails/${Date.now()}-${attachment.filename}`,
          attachment.content
        );
      }
    }

    await message.forward('inbox@yourdomain.com');
  },
};

Email-Based Task Creation

import PostalMime from 'postal-mime';

export default {
  async email(message, env, ctx) {
    const parser = new PostalMime.default();
    const email = await parser.parse(await new Response(message.raw).arrayBuffer());

    // Extract task from email subject
    const taskMatch = email.subject.match(/\[TASK\](.*)/i);

    if (taskMatch) {
      const taskDescription = taskMatch[1].trim();

      // Create task in D1
      await env.DB.prepare(
        'INSERT INTO tasks (description, created_by, created_at) VALUES (?, ?, ?)'
      ).bind(
        taskDescription,
        message.from,
        new Date().toISOString()
      ).run();

      // Send confirmation
      await message.reply(new EmailMessage(
        'tasks@yourdomain.com',
        message.from,
        `Task created: ${taskDescription}`
      ));
    }
  },
};

Email-Triggered Workflows

export default {
  async email(message, env, ctx) {
    // Trigger Cloudflare Workflow based on email
    if (message.from.endsWith('@trusted-domain.com')) {
      await env.WORKFLOW.create({
        params: {
          emailFrom: message.from,
          emailTo: message.to,
          receivedAt: new Date().toISOString(),
        },
      });
    }

    await message.forward('inbox@yourdomain.com');
  },
};

Dependencies

Required:

  • postal-mime@2.5.0 - Parse incoming email messages
  • mimetext@3.0.27 - Create email messages for sending

Built-in:

  • cloudflare:email - EmailMessage class (no installation needed)

Optional:

  • @cloudflare/workers-types - TypeScript type definitions

Official Documentation


Package Versions (Verified 2025-10-23)

{
  "dependencies": {
    "postal-mime": "^2.5.0",
    "mimetext": "^3.0.27"
  },
  "devDependencies": {
    "@cloudflare/workers-types": "^4.20251014.0",
    "wrangler": "^4.44.0"
  }
}

Questions? Issues?

  1. Check references/common-errors.md for detailed troubleshooting
  2. Review references/dns-setup.md for DNS configuration help
  3. See references/local-development.md for testing patterns
  4. Check official docs: https://developers.cloudflare.com/email-routing/
  5. Use wrangler tail for live debugging
  6. Verify all destination addresses are verified in dashboard

平台分布

Claude Code

27.78%
按下载量换算80

Codex

23.29%
按下载量换算67

windsurf

18.4%
按下载量换算53

OpenCode

11.24%
按下载量换算32

Cursor

7.13%
按下载量换算21

Antigravity

3.25%
按下载量换算9

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills