Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/email-routing/README.md
1# Cloudflare Email Routing Skill Reference23## Overview45Cloudflare Email Routing enables custom email addresses for your domain that route to verified destination addresses. It's free, privacy-focused (no storage/access), and includes Email Workers for programmatic email processing.67**Available to all Cloudflare customers using Cloudflare as authoritative nameserver.**89## Quick Start1011```typescript12// Basic email handler13export default {14async email(message, env, ctx) {15// CRITICAL: Must consume stream before response16const parser = new PostalMime.default();17const email = await parser.parse(await message.raw.arrayBuffer());1819// Process email20console.log(`From: ${message.from}, Subject: ${email.subject}`);2122// Forward or reject23await message.forward("[email protected]");24}25} satisfies ExportedHandler<Env>;26```2728## Reading Order2930**Start here based on your goal:**31321. **New to Email Routing?** → [configuration.md](configuration.md) → [patterns.md](patterns.md)332. **Adding Workers?** → [api.md](api.md) § Worker Runtime API → [patterns.md](patterns.md)343. **Sending emails?** → [api.md](api.md) § SendEmail Binding354. **Managing via API?** → [api.md](api.md) § REST API Operations365. **Debugging issues?** → [gotchas.md](gotchas.md)3738## Decision Tree3940```41Need to receive emails?42├─ Simple forwarding only? → Dashboard rules (configuration.md)43├─ Complex logic/filtering? → Email Workers (api.md + patterns.md)44└─ Parse attachments/body? → postal-mime library (patterns.md § Parse Email)4546Need to send emails?47├─ From Worker? → SendEmail binding (api.md § SendEmail)48└─ From external app? → Use external SMTP/API service4950Having issues?51├─ Email not arriving? → gotchas.md § Mail Authentication52├─ Worker crashing? → gotchas.md § Stream Consumption53└─ Forward failing? → gotchas.md § Destination Verification54```5556## Key Concepts5758**Routing Rules**: Pattern-based forwarding configured via Dashboard/API. Simple but limited.5960**Email Workers**: Custom TypeScript handlers with full email access. Handles complex logic, parsing, storage, rejection.6162**SendEmail Binding**: Outbound email API for Workers. Transactional email only (no marketing/bulk).6364**ForwardableEmailMessage**: Runtime interface for incoming emails. Provides headers, raw stream, forward/reject methods.6566## In This Reference6768- **[configuration.md](configuration.md)** - Setup, deployment, wrangler config69- **[api.md](api.md)** - REST API + Worker runtime API + types70- **[patterns.md](patterns.md)** - Common patterns with working examples71- **[gotchas.md](gotchas.md)** - Critical pitfalls, troubleshooting, limits7273## Architecture7475```76Internet → MX Records → Cloudflare Email Routing77├─ Routing Rules (dashboard)78└─ Email Worker (your code)79├─ Forward to destination80├─ Reject with reason81├─ Store in R2/KV/D182└─ Send outbound (SendEmail)83```8485## See Also8687- [Cloudflare Docs: Email Routing](https://developers.cloudflare.com/email-routing/)88- [Cloudflare Docs: Email Workers](https://developers.cloudflare.com/email-routing/email-workers/)89- [postal-mime npm package](https://www.npmjs.com/package/postal-mime)90