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
* update types and add note for service worker
* Update src/content/docs/email-routing/email-workers/runtime-api.mdx
* Retrigger CI
---------
Co-authored-by: ToriLindsay <[email protected]>
Co-authored-by: Kody Jackson <[email protected]>
Copy file name to clipboardExpand all lines: src/content/docs/email-routing/email-workers/runtime-api.mdx
+54-28Lines changed: 54 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,28 +10,6 @@ sidebar:
10
10
11
11
An `EmailEvent` is the event type to programmatically process your emails with a Worker. You can reject, forward, or drop emails according to the logic you construct in your Worker.
12
12
13
-
***
14
-
15
-
## Syntax: Service Worker
16
-
17
-
`EmailEvent` can be handled in Workers functions written using the Service Worker syntax by attaching to the `email` event with `addEventListener`:
18
-
19
-
```js
20
-
addEventListener("email", async (event) => {
21
-
awaitevent.message.forward("<YOUR_EMAIL>");
22
-
});
23
-
```
24
-
25
-
### Properties
26
-
27
-
28
-
29
-
*`event.message` EmailMessage
30
-
31
-
* An [`EmailMessage` object](#emailmessage-definition).
Service Workers are deprecated but still supported. We recommend using [Module Workers](/workers/reference/migrate-to-module-workers/) instead. New features may not be supported for Service Workers.
51
+
52
+
:::
53
+
54
+
`EmailEvent` can be handled in Workers functions written using the Service Worker syntax by attaching to the `email` event with `addEventListener`:
55
+
56
+
```js
57
+
addEventListener("email", async (event) => {
58
+
awaitevent.message.forward("<YOUR_EMAIL>");
59
+
});
60
+
```
61
+
62
+
### Properties
63
+
64
+
65
+
66
+
*`event.message` ForwardableEmailMessage
67
+
68
+
* An [`ForwardableEmailMessage` object](#forwardableemailmessage-definition).
69
+
70
+
71
+
72
+
***
73
+
74
+
## `ForwardableEmailMessage` definition
69
75
70
76
```ts
71
-
interfaceEmailMessage<Body=unknown> {
77
+
interfaceForwardableEmailMessage<Body=unknown> {
72
78
readonly from:string;
73
79
readonly to:string;
74
80
readonly headers:Headers;
@@ -83,7 +89,7 @@ export default {
83
89
}
84
90
```
85
91
86
-
92
+
An email message that is sent to a consumer Worker and can be rejected/forwarded.
87
93
88
94
*`from` string
89
95
@@ -114,7 +120,27 @@ export default {
114
120
* Forward this email message to a verified destination address of the account. If you want, you can add extra headers to the email message. Only `X-*` headers are allowed.
115
121
* When the promise resolves, the message is confirmed to be forwarded to a verified destination address.
0 commit comments