Email worker, with fetch, sending to API

I am trying to set up a catch-all email, and send all incoming emails to a worker. The work is to send the email to my API. the API will then handle the rest. Right now, I am getting rejected emails that the address dose not exist. While editing the worker, I noticed "Error: No fetch handler!"
export default {
async email(message, env, ctx) {
const response = await fetch('https://api.domain.tld', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({email:message}),
});
if (!response.ok) {}
const data = await response.json();
}
}
export default {
async email(message, env, ctx) {
const response = await fetch('https://api.domain.tld', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({email:message}),
});
if (!response.ok) {}
const data = await response.json();
}
}
2 Replies
布鲁诺 普雷托
GitHub
cloudflare-worker-emails-to-discord/index.js at master · Tyler-OBri...
Use Email Workers to forward the emails you receive to a discord webhook - Tyler-OBrien/cloudflare-worker-emails-to-discord
布鲁诺 普雷托
You cant send message like that, the body is a Stream, u need to 'process' it Refer to this Forum post : https://discord.com/channels/595317990191398933/1209897275816411136
Want results from more Discord servers?
Add your server