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
Copy file name to clipboardExpand all lines: src/content/docs/email-routing/email-workers/local-development.mdx
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,11 +32,11 @@ If you want to deploy your script you need to [enable Email Routing](/email-rout
32
32
33
33
:::
34
34
35
-
You can now test receiving, replying and sending emails in your local environment.
35
+
You can now test receiving, replying, and sending emails in your local environment.
36
36
37
-
## Receiving an email
37
+
## Receive an email
38
38
39
-
Consider this example Email Worker script that uses the opensource [postal-mime](https://www.npmjs.com/package/postal-mime) email parser:
39
+
Consider this example Email Worker script that uses the open source [`postal-mime`](https://www.npmjs.com/package/postal-mime) email parser:
40
40
41
41
```ts
42
42
import*asPostalMimefrom'postal-mime';
@@ -54,7 +54,7 @@ export default {
54
54
Now when you run `npx wrangler dev`, wrangler will expose a local `/cdn-cgi/handler/email` endpoint that you can `POST` email messages to and trigger your Worker's `email()` handler:
55
55
56
56
```bash
57
-
curl -X POST 'http://localhost:8787/cdn-cgi/handler/email' \
57
+
curl --request POST 'http://localhost:8787/cdn-cgi/handler/email' \
@@ -105,9 +105,9 @@ This is what you get in the console:
105
105
}
106
106
```
107
107
108
-
## Sending an email
108
+
## Send an email
109
109
110
-
Wrangler can also simulate sending emails locally. Consider this example Email Worker script that uses the [mimetext](https://www.npmjs.com/package/mimetext) npm package:
110
+
Wrangler can also simulate sending emails locally. Consider this example Email Worker script that uses the [`mimetext`](https://www.npmjs.com/package/mimetext) npm package:
111
111
112
112
```ts
113
113
import { EmailMessage } from"cloudflare:email";
@@ -133,7 +133,7 @@ export default {
133
133
134
134
Now when you run `npx wrangler dev`, go to http://localhost:8787/ to trigger the `fetch()` handler and send the email. You will see the follow message in your terminal:
Congratulations, you just sent an email from a worker.
157
157
```
158
158
159
-
## Replying to and forwarding messages
159
+
## Reply to and forward messages
160
160
161
161
Likewise, [`EmailMessage`](/email-routing/email-workers/runtime-api/#emailmessage-definition)'s `forward()` and `reply()` methods are also simulated locally. Consider this Worker that receives an email, parses it, replies to the sender, and forwards the original message to one your verified recipient addresses:
162
162
@@ -194,9 +194,9 @@ export default {
194
194
};
195
195
```
196
196
197
-
Run `npx wrangler dev` and use curl to POST the same message from the [Receiving an email](#receiving-an-email) example. Your terminal will show you where to find the replied message in your local disk and to whom the email was forwarded:
197
+
Run `npx wrangler dev` and use curl to `POST` the same message from the [Receive an email](#receive-an-email) example. Your terminal will show you where to find the replied message in your local disk and to whom the email was forwarded:
198
198
199
-
```bash
199
+
```txt
200
200
⎔ Starting local server...
201
201
[wrangler:inf] Ready on http://localhost:8787
202
202
[wrangler:inf] Email handler replied to sender with the following message:
0 commit comments