You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bd560bf
Browse filesBrowse the repository at this point in the historyBrowse files
|`ctx`|`object`| Execution context with `waitUntil` function |
48
+
ES module handlers receive `message`, `env`, and `ctx` as arguments. `WorkerEntrypoint` subclasses — including Python `WorkerEntrypoint` classes and JavaScript or TypeScript class entrypoints — receive only `message`. Access bindings and execution context through `self.env` and `self.ctx` in Python, or `this.env` and `this.ctx` in JavaScript and TypeScript.
Copy file name to clipboardExpand all lines: src/content/docs/email-service/get-started/route-emails.mdx
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,10 @@ Verify that your routing rule is working:
84
84
85
85
Use Workers to process emails with custom logic before forwarding or responding.
86
86
87
+
### Prerequisites
88
+
89
+
Because this Worker calls `message.forward()`, the forwarding address must be a verified destination address on your Cloudflare account. Before you deploy or test the Worker, add and verify the destination address in the Cloudflare dashboard. To add and verify an address, refer to [Add a destination address](/email-service/configuration/destination-addresses/#add-a-destination-address).
90
+
87
91
### Create an email processing Worker
88
92
89
93
1. Create a new Worker project:
@@ -126,7 +130,7 @@ Use Workers to process emails with custom logic before forwarding or responding.
126
130
// Configuration - Update these values
127
131
// ============================================
128
132
const YOUR_DOMAIN ="yourdomain.com"; // Replace with your verified domain
129
-
const FORWARD_TO_EMAIL ="your-team@example.com"; // Replace with where you want emails forwarded
133
+
const FORWARD_TO_EMAIL ="your-team@example.com"; // Replace with a verified destination address on your account
130
134
131
135
exportdefault {
132
136
async email(message, env, ctx):Promise<void> {
@@ -144,8 +148,8 @@ Use Workers to process emails with custom logic before forwarding or responding.
// Email Service populates References automatically to preserve the full thread chain
147
152
msg.setHeader("In-Reply-To", messageId);
148
-
msg.setHeader("References", messageId);
149
153
}
150
154
msg.setSender({
151
155
name: "Support Team",
@@ -187,7 +191,9 @@ Use Workers to process emails with custom logic before forwarding or responding.
187
191
:::caution[Update configuration]
188
192
Before deploying, update the constants at the top of the file:
189
193
-`YOUR_DOMAIN`: Your verified domain from the Cloudflare dashboard
190
-
-`FORWARD_TO_EMAIL`: The email address where you want to receive forwarded emails
194
+
-`FORWARD_TO_EMAIL`: A verified destination address on your Cloudflare account
195
+
196
+
Calls to `message.forward()` fail if `FORWARD_TO_EMAIL` is not verified on your account. To add and verify an address, refer to [Add a destination address](/email-service/configuration/destination-addresses/#add-a-destination-address).
0 commit comments