Email worker doesn't work, logs and tail are empty
I have a very simple worker:
Whenever I send an email to the address the worker is supposed to work for, it's rejected. I only see it in the email routing dashboard, and the error message is
The logs are empty,
export interface Env {
EMAIL_TO: string;
WEBHOOK_ID: string;
WEBHOOK_TOKEN: string;
}
export default {
async email(message, env, ctx) {
const webhookUrl = `https://discord.com/api/webhooks/${env.WEBHOOK_ID}/${env.WEBHOOK_TOKEN}`;
console.log(`New email from ${message.from}`);
const embed = {
title: "You've got mail!",
author: {
name: message.from,
},
description: new Date().toISOString(),
};
const msg = {
content: "You've got mail!",
embeds: [embed],
};
try {
const res = await fetch(webhookUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(msg),
});
if (!res.ok) {
console.log(`Discord webhook failed: ${res.statusText}`);
console.log(await res.text());
}
} catch (e) {
console.log(e);
}
await message.forward(env.EMAIL_TO);
},
} satisfies ExportedHandler<Env>;export interface Env {
EMAIL_TO: string;
WEBHOOK_ID: string;
WEBHOOK_TOKEN: string;
}
export default {
async email(message, env, ctx) {
const webhookUrl = `https://discord.com/api/webhooks/${env.WEBHOOK_ID}/${env.WEBHOOK_TOKEN}`;
console.log(`New email from ${message.from}`);
const embed = {
title: "You've got mail!",
author: {
name: message.from,
},
description: new Date().toISOString(),
};
const msg = {
content: "You've got mail!",
embeds: [embed],
};
try {
const res = await fetch(webhookUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(msg),
});
if (!res.ok) {
console.log(`Discord webhook failed: ${res.statusText}`);
console.log(await res.text());
}
} catch (e) {
console.log(e);
}
await message.forward(env.EMAIL_TO);
},
} satisfies ExportedHandler<Env>;name = "contact-discord-notif"
main = "src/index.ts"
compatibility_date = "2025-03-03"
[observability]
enabled = truename = "contact-discord-notif"
main = "src/index.ts"
compatibility_date = "2025-03-03"
[observability]
enabled = trueWhenever I send an email to the address the worker is supposed to work for, it's rejected. I only see it in the email routing dashboard, and the error message is
Worker call resulted in an error: Worker call failed for 3 times, aborting...Worker call resulted in an error: Worker call failed for 3 times, aborting...The logs are empty,
wrangler tailwrangler tail gives me no output either.