Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion public/__redirects
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,14 @@
/durable-objects/what-are-durable-objects/ /durable-objects/concepts/what-are-durable-objects/ 301
/durable-objects/observability/graphql-analytics/ /durable-objects/observability/metrics-and-analytics/ 301

# Email Service information architecture
/email-service/local-development/ /email-service/observability/local-development/ 301
/email-service/local-development/sending/ /email-service/observability/local-development/sending/ 301
/email-service/local-development/routing/ /email-service/observability/local-development/routing/ 301
/email-service/platform/email-routing-rest-api/ /email-service/api/email-routing-rest-api/ 301
/email-service/platform/email-sending-rest-api/ /email-service/api/email-sending-rest-api/ 301
/email-service/platform/event-subscriptions/ /email-service/reference/event-subscriptions/ 301

# Email Routing -> Email Service (product merged)
# Top-level
/email-routing/ /email-service/ 301
Expand Down Expand Up @@ -902,7 +910,7 @@
/email-routing/email-workers/reply-email-workers/ /email-service/api/route-emails/email-handler/#reply-to-emails 301
/email-routing/email-workers/send-email-workers/ /email-service/api/send-emails/workers-api/ 301
/email-routing/email-workers/runtime-api/ /email-service/api/route-emails/email-handler/ 301
/email-routing/email-workers/local-development/ /email-service/local-development/routing/ 301
/email-routing/email-workers/local-development/ /email-service/observability/local-development/routing/ 301

# Troubleshooting
/email-routing/troubleshooting/ /email-service/reference/troubleshooting/ 301
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ This is what you get in the console:
}
```

Local development is a critical part of the development flow, and also works for sending, replying and forwarding emails. See [our documentation](/email-service/local-development/routing/) for more information.
Local development is part of the development flow. It also works for sending, replying, and forwarding emails. For more information, refer to [local development for email routing](/email-service/observability/local-development/routing/).
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ Each event includes the message details, delivery status, and SMTP response:
}
```

Refer to [Event subscriptions](/email-service/platform/event-subscriptions/) to see all event types and example payloads.
Refer to [Event subscriptions](/email-service/reference/event-subscriptions/) to see all event types and example payloads.
4 changes: 2 additions & 2 deletions src/content/docs/email-service/api/index.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: API reference
title: API
description: REST API and Workers API reference for sending and routing emails with Email Service.
pcx_content_type: navigation
sidebar:
order: 5
order: 8
group:
hideIndex: true
products:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ async function processEmail(message, env) {

## Next steps

- Test locally: [Email routing development](/email-service/local-development/routing/)
- Manage rules and addresses programmatically with the [Email Routing REST API](/email-service/platform/email-routing-rest-api/)
- Test locally: [Email routing development](/email-service/observability/local-development/routing/)
- Manage rules and addresses programmatically with the [Email Routing REST API](/email-service/api/email-routing-rest-api/)
- Set up [email routing configuration](/email-service/configuration/email-routing-addresses/)
- See [email routing examples](/email-service/examples/email-routing/) for advanced email processing
- Learn about [spam filtering](/email-service/examples/email-routing/spam-filtering/) with Workers
12 changes: 6 additions & 6 deletions src/content/docs/email-service/api/send-emails/rest-api.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: REST API
description: Send emails from any application using the Email Service REST API with standard HTTP requests.
pcx_content_type: concept
description: Email Sending REST API requests, responses, authentication, and errors.
pcx_content_type: reference
sidebar:
order: 2
products:
Expand All @@ -22,7 +22,7 @@ Authenticate with a [Cloudflare API token](/fundamentals/api/get-started/create-
Authorization: Bearer <API_TOKEN>
```

## Send an email
## Request example

```bash
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/email/sending/send" \
Expand Down Expand Up @@ -111,7 +111,7 @@ A successful response returns the delivery status for each recipient:
The REST API returns recipient-grouped delivery status. The [Workers binding](/email-service/api/send-emails/workers-api/) returns a single `messageId` per `send()` call instead.
:::

## Error handling
## Error responses

The REST API returns standard Cloudflare API error responses. A failed request returns an `errors` array with numeric error codes and machine-readable messages:

Expand Down Expand Up @@ -152,9 +152,9 @@ REST API error codes:
The REST API returns standard Cloudflare API numeric error codes, while the [Workers binding](/email-service/api/send-emails/workers-api/) throws errors with string codes (for example, `E_SENDER_NOT_VERIFIED`). Refer to the [Workers API error codes table](/email-service/api/send-emails/workers-api/#error-codes) for the string error codes.
:::

## Next steps
## Related resources

- Refer to the [Email Sending API reference](/api/resources/email_sending/methods/send/) for the full request and response schemas.
- See the [Workers API](/email-service/api/send-emails/workers-api/) for sending emails directly from Cloudflare Workers using bindings.
- Refer to the [Email Sending Workers API](/email-service/api/send-emails/workers-api/) for sending emails directly from Cloudflare Workers using bindings.
- See [SMTP](/email-service/api/send-emails/smtp/) for sending from any SMTP-capable application or mail client.
- Review [email headers](/email-service/reference/headers/) for threading, list management, and custom tracking headers.
6 changes: 3 additions & 3 deletions src/content/docs/email-service/api/send-emails/smtp.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: SMTP
description: Send emails from any SMTP-capable application or mail client using authenticated SMTP submission on smtp.mx.cloudflare.net.
pcx_content_type: concept
description: Email Service SMTP endpoint, authentication, limits, responses, and errors.
pcx_content_type: reference
sidebar:
order: 3
products:
Expand Down Expand Up @@ -179,7 +179,7 @@ For authentication problems related to SPF, DKIM, or DMARC on the recipient side

- [Send email over SMTP](/email-service/examples/email-sending/smtp/) — examples for curl, Nodemailer, Python, and PHP.
- [REST API](/email-service/api/send-emails/rest-api/) — send emails over HTTPS.
- [Workers API](/email-service/api/send-emails/workers-api/) — send emails from a Cloudflare Worker using bindings.
- [Email Sending Workers API](/email-service/api/send-emails/workers-api/) — send emails from a Cloudflare Worker using bindings.
- [Domain configuration](/email-service/configuration/domains/) — onboard a domain for Email Sending.
- [MTA-STS](/email-service/configuration/mta-sts/) — enforce TLS for incoming mail.
- [Email headers](/email-service/reference/headers/) — supported headers and threading hints.
Expand Down
10 changes: 5 additions & 5 deletions src/content/docs/email-service/api/send-emails/workers-api.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Workers API
description: Send emails directly from Cloudflare Workers using the Email Service binding and send() method.
pcx_content_type: concept
title: Email Sending Workers API
description: Email Sending Workers API methods, types, binding, and errors.
pcx_content_type: reference
sidebar:
order: 1
products:
Expand All @@ -27,7 +27,7 @@ Configure a `send_email` binding in your Wrangler configuration file to enable e

</WranglerConfig>

You can restrict which senders and recipients a binding may use. Refer to [Configure send bindings](/email-service/configuration/send-bindings/) for the available restriction attributes and examples.
You can restrict which senders and recipients a binding may use. Refer to [send bindings](/email-service/configuration/send-bindings/) for the available restriction attributes and examples.

## `send()` method

Expand Down Expand Up @@ -79,7 +79,7 @@ interface EmailSendResult {
```

:::note[Local development with binary attachments]
When using `wrangler dev` without [remote bindings](/workers/local-development/#remote-bindings), `ArrayBuffer` and `ArrayBufferView` content in attachments cannot be serialized by the local simulator. Refer to [local development for email sending](/email-service/local-development/sending/#known-limitations).
When using `wrangler dev` without [remote bindings](/workers/local-development/#remote-bindings), `ArrayBuffer` and `ArrayBufferView` content in attachments cannot be serialized by the local simulator. Refer to [local development for email sending](/email-service/observability/local-development/sending/#known-limitations).
:::

### Basic usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ If a routing rule for `user+detail@example.com` already exists, it takes precede
## Next steps

- [Email handler](/email-service/api/route-emails/email-handler/) — process emails programmatically with the `email()` handler.
- [Email Routing REST API](/email-service/platform/email-routing-rest-api/) — manage routing rules and destination addresses programmatically.
- [Email Routing REST API](/email-service/api/email-routing-rest-api/) — manage routing rules and destination addresses programmatically.
- [Domain configuration](/email-service/configuration/domains/) — manage DNS records for Email Routing.
- [Email routing examples](/email-service/examples/email-routing/) — advanced patterns including spam filtering and email storage.
2 changes: 1 addition & 1 deletion src/content/docs/email-service/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Configuration
description: Configure domains, routing rules, suppressions, and MTA-STS for Cloudflare Email Service.
pcx_content_type: navigation
sidebar:
order: 4
order: 6
group:
hideIndex: true
products:
Expand Down
12 changes: 6 additions & 6 deletions src/content/docs/email-service/configuration/send-bindings.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Configure send bindings
description: Restrict which senders and recipients a Workers send_email binding can use with Email Service.
pcx_content_type: how-to
title: Send bindings
description: Email Service send binding restrictions and Wrangler configuration variants.
pcx_content_type: configuration
sidebar:
order: 5
products:
Expand All @@ -10,11 +10,11 @@ products:

import { WranglerConfig } from "~/components";

When you add a `send_email` binding to a Worker, you can restrict which addresses it may send from and to. Configure these restrictions in your Wrangler configuration file. For the binding API itself, refer to the [Workers API](/email-service/api/send-emails/workers-api/).
When you add a `send_email` binding to a Worker, you can restrict its sender and recipient addresses. The following Wrangler configuration variants apply these restrictions. For the binding API, refer to the [Email Sending Workers API](/email-service/api/send-emails/workers-api/).

## Binding types

Each entry in `send_email` can be configured to restrict what the binding can do. The sender address must always belong to a domain you have onboarded to Email Service.
Each `send_email` entry supports a different restriction choice. The sender address must belong to an onboarded Email Service domain.

- **No restriction attribute**: The binding can send to any verified destination address in your account.
- **`destination_address`**: The binding can only send to the single destination address configured here. If you call `send()` with `to` set to `null` or `undefined`, the configured address is used.
Expand Down Expand Up @@ -57,5 +57,5 @@ Each entry in `send_email` can be configured to restrict what the binding can do

## Next steps

- [Workers API](/email-service/api/send-emails/workers-api/) — send emails from a Worker using the binding.
- [Email Sending Workers API](/email-service/api/send-emails/workers-api/) — send emails from a Worker using the binding.
- [Domain configuration](/email-service/configuration/domains/) — onboard the domains you send from.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Subdomains
title: Configure subdomains
description: Configure Email Sending and Email Routing on subdomains within your zone.
pcx_content_type: how-to
sidebar:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Handle hard bounce emails
description: Detect and process hard bounce notifications in Email Service to maintain sender reputation.
pcx_content_type: how-to
title: Hard bounce handling
description: Detect hard bounce notifications and store recipients in Workers KV.
pcx_content_type: example
summary: Detect and handle hard bounce emails to maintain sender reputation and manage undeliverable addresses
sidebar:
order: 4
Expand All @@ -11,9 +11,9 @@ products:

import { WranglerConfig } from "~/components";

Handle hard bounce notifications to automatically remove invalid email addresses from your mailing lists and maintain good sender reputation.
This example detects hard bounce notifications and stores recipient addresses in Workers KV.

## What are hard bounces?
## Identify hard bounces

Hard bounces occur when an email cannot be delivered due to permanent reasons:

Expand All @@ -22,7 +22,7 @@ Hard bounces occur when an email cannot be delivered due to permanent reasons:
- Mailbox full: The recipient's mailbox has exceeded storage limits
- Email blocked: The recipient's server permanently rejects emails

## Configuration
## Configure bindings

Configure your worker to handle bounce notifications:

Expand All @@ -44,7 +44,7 @@ Configure your worker to handle bounce notifications:

</WranglerConfig>

## Hard bounce detection
## Detect hard bounces

```javascript
import * as PostalMime from "postal-mime";
Expand Down Expand Up @@ -187,7 +187,7 @@ async function handleHardBounce(bounceInfo, env) {
}
```

## Testing hard bounce handling
## Test the handler

Create a test bounce notification:

Expand Down Expand Up @@ -222,7 +222,7 @@ Message-ID: <original123@yourdomain.com>
Welcome! Thanks for signing up.'
```

## Checking suppression list
## Check the suppression list

Add a utility function to check if an email is suppressed before sending:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: Spam filtering
description: Build spam detection for Email Service with keyword analysis, domain reputation checks, and AI-based filtering.
description: Filter email with subject keywords and trusted-domain heuristics.
pcx_content_type: example
summary: Implement intelligent spam detection with keyword analysis, domain reputation, and machine learning techniques
summary: Filter email with subject keywords and trusted-domain heuristics
sidebar:
order: 2
products:
- email-service
---

Build spam filtering systems with keyword matching, domain validation, and intelligent detection methods for effective email security.
This example scores incoming email using subject keywords and sender-domain heuristics.

## Basic spam filter

Expand Down Expand Up @@ -153,9 +153,9 @@ function getScoreRange(score: number): string {
}
```

## Advanced spam detection with AI
## Optional Workers AI integration

For more sophisticated spam detection, you can enhance the basic filter using [Workers AI](/workers-ai/) to analyze email content with machine learning models. This approach can identify subtle spam patterns that keyword-based filters might miss.
The basic spam filter uses simple heuristic checks. You can optionally use [Workers AI](/workers-ai/) to analyze email content.

## Next steps

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
summary: Implement passwordless authentication by sending secure, time-limited login links via email.
summary: Generate and email a login link from a Worker.
pcx_content_type: example
title: Magic link authentication
description: Passwordless login system using magic links sent via email with JWT tokens and session management.
title: Email a login link
description: Generate and email a login link from a Worker.
sidebar:
order: 7
products:
Expand All @@ -11,7 +11,7 @@ products:

import { WranglerConfig } from "~/components";

This example demonstrates how to send a magic link email for passwordless authentication using Cloudflare Email Service.
This example generates a login link and emails it with Cloudflare Email Service.

Configure the email binding in your Wrangler configuration file:

Expand All @@ -28,7 +28,7 @@ Configure the email binding in your Wrangler configuration file:

</WranglerConfig>

The Worker exposes a `POST /send-magic-link` route that validates the submitted email address, generates a single-use token, and emails the recipient a time-limited login link. The following code implements that handler.
The Worker exposes a `POST /send-magic-link` route. It checks the email address, generates a random token, and emails a login link.

```typescript
interface Env {
Expand Down Expand Up @@ -60,7 +60,7 @@ async function handleSendMagicLink(
});
}

// Generate a simple secure token (you would implement proper JWT/token handling)
// Generate a random token for the login link
const token = crypto.randomUUID();
const magicUrl = `https://${env.DOMAIN}/login?token=${token}`;

Expand All @@ -73,14 +73,12 @@ async function handleSendMagicLink(
<h1>Login to your account</h1>
<p>Click the link below to log in:</p>
<p><a href="${magicUrl}">Login Now</a></p>
<p>This link expires in 15 minutes.</p>
`,
text: `
Login to your account

Click this link to log in: ${magicUrl}

This link expires in 15 minutes.
`,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,6 @@ function isValidEmail(email: string): boolean {

## Next steps

- [Magic link authentication](/email-service/examples/email-sending/magic-link/) — passwordless login flow using a similar token pattern.
- [Email a login link](/email-service/examples/email-sending/magic-link/) — generate and email a link using a similar token pattern.
- [Send method](/email-service/api/send-emails/workers-api/) — full reference for the `send()` method.
- [Deliverability](/email-service/concepts/deliverability/) — keep verification emails out of spam folders.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
WranglerConfig,
} from "~/components";

Use [Email Sending event subscriptions](/email-service/platform/event-subscriptions/) to update application records after delivery problems. This example uses [Cloudflare Queues](/queues/) and [Workers KV](/kv/) to remove recipients from transactional notifications.
Use [Email Sending event subscriptions](/email-service/reference/event-subscriptions/) to update application records after delivery problems. This example uses [Cloudflare Queues](/queues/) and [Workers KV](/kv/) to remove recipients from transactional notifications.

:::note[Suppression lists]
Email Sending automatically [suppresses](/email-service/concepts/suppressions/) hard bounces and spam complaints. This example also prevents your application from selecting those recipients.
Expand Down Expand Up @@ -47,7 +47,7 @@ Remove records for every `message.complained` event. These events indicate that

Remove bounced records only when `payload.bounce.type` is `"hard"`. Temporary failures produce `message.deferred` events while retries remain. Exhausted temporary retries can produce `message.bounced` events with a `"soft"` bounce type.

For payload details, refer to [Available Email Sending events](/email-service/platform/event-subscriptions/#available-email-sending-events).
For payload details, refer to [Available Email Sending events](/email-service/reference/event-subscriptions/#available-email-sending-events).

## Create the queue and subscription

Expand Down Expand Up @@ -175,7 +175,7 @@ Monitor the dead letter queue for failed events. Reprocess them after fixing the

## Explore related resources

- [Event subscriptions](/email-service/platform/event-subscriptions/) — review event schemas.
- [Event subscriptions](/email-service/reference/event-subscriptions/) — review event schemas.
- [Suppression lists](/email-service/concepts/suppressions/) — understand automatic suppressions.
- [Queues retries](/queues/configuration/batching-retries/) — control message retries.
- [Workers KV consistency](/kv/concepts/how-kv-works/#consistency) — account for propagation delays.
2 changes: 1 addition & 1 deletion src/content/docs/email-service/examples/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Examples
description: Practical code examples for sending and routing emails with Cloudflare Email Service.
pcx_content_type: navigation
sidebar:
order: 6
order: 5
group:
hideIndex: true
products:
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/email-service/get-started/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Getting started
title: Get started
description: Set up Cloudflare Email Service to send transactional emails and route incoming messages.
pcx_content_type: navigation
sidebar:
Expand Down
Loading