email worker not working

I have a worker that follows the example but the reject doesn't seem to happen
3 Replies
RhinosF1
RhinosF113mo ago
export default { async email(message, env, ctx) { const block = ["[email protected]", "[email protected]"] if (block.indexOf(message.headers.get("from")) == -1) { await message.forward("[email protected]"); } else { message.setReject("Rejected. You are not authorised to send to this email."); } } } i know it's running the worker when I send from [email protected] because the +spamfiltered gets added used message.from instead
Chaika
Chaika13mo ago
yea there's a big difference between message.from (Envelope from) and message.headers.get from (header from), if you haven't found already: https://www.xeams.com/difference-envelope-header.htm Header from can contain the name of the sender, ex: Jack Smith <[email protected]>., which is why it wasn't matching
RhinosF1
RhinosF113mo ago
@Chaika unfortunately that's what the example gave realised it with a few console.log entries had to send actual emails as the tester was never loading too
Want results from more Discord servers?
Add your server