Sven
Sven
Explore posts from servers
CDCloudflare Developers
Created by Sven on 2/21/2024 in #workers-help
Getting the body from a email-worker.
That code will help me indeed with getting it to work faster :) Ty!
18 replies
CDCloudflare Developers
Created by Sven on 2/21/2024 in #workers-help
Getting the body from a email-worker.
Thanks! (both of you)
18 replies
CDCloudflare Developers
Created by Sven on 2/21/2024 in #workers-help
Getting the body from a email-worker.
Yea, only problem is I dont know how stream's work... I have read the docs but couldn't figure it out ;(
export default {
async email(message, env, ctx) {
switch (message.to) {
case "EMAIL_CASE":
await fetch("API_ENDPOINT", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"icon": "📨",
"title": message.headers.get('subject'),
"body": readable.getReader({ mode: 'byob' }),
"source": message.from,
}),
});
break;
default:
message.reject("Unknown address");
}
}
}
export default {
async email(message, env, ctx) {
switch (message.to) {
case "EMAIL_CASE":
await fetch("API_ENDPOINT", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"icon": "📨",
"title": message.headers.get('subject'),
"body": readable.getReader({ mode: 'byob' }),
"source": message.from,
}),
});
break;
default:
message.reject("Unknown address");
}
}
}
18 replies
CDCloudflare Developers
Created by Sven on 2/21/2024 in #workers-help
Getting the body from a email-worker.
I meant the body of the recieved email :)
18 replies