Skip to content

[Email Routing] Added reference to runtime api #22206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
Merged
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
25 changes: 13 additions & 12 deletions src/content/docs/email-routing/email-workers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: Email Workers
pcx_content_type: concept
sidebar:
order: 4

---

With Email Workers you can leverage the power of Cloudflare Workers to implement any logic you need to process your emails and create complex rules. These rules determine what happens when you receive an email.
Expand All @@ -16,15 +15,15 @@ The following is an example of an allowlist Email Worker:

```js
export default {
async email(message, env, ctx) {
const allowList = ["[email protected]", "[email protected]"];
if (allowList.indexOf(message.from) == -1) {
message.setReject("Address not allowed");
} else {
await message.forward("inbox@corp");
}
}
}
async email(message, env, ctx) {
const allowList = ["[email protected]", "[email protected]"];
if (allowList.indexOf(message.from) == -1) {
message.setReject("Address not allowed");
} else {
await message.forward("inbox@corp");
}
},
};
```

Refer to the [Workers Languages](/workers/languages/) for more information regarding the languages you can use with Workers.
Expand All @@ -41,6 +40,8 @@ The route, or email address, bound to the Worker forwards emails to your Email W

For example, say that you create an allowlist Email Worker and bind it to a `[email protected]` route. This route will be the email address you share with the world, to make sure that only email addresses on your allowlist are forwarded to your destination address. All other emails will be dropped.

## Limits
## Resources

If you encounter any allocation errors while using Email Workers, refer to [Limits](/email-routing/limits/#email-workers-size-limits) for more information.
- [Limits](/email-routing/limits/#email-workers-size-limits)
- [Runtime API](/email-routing/email-workers/runtime-api/)
- [Local development](/email-routing/email-workers/local-development/)