How do i do this?
So for a special purpose i am trying to forward all emails to 5 seperate emails, how do i do this?
email workers btw
this is my current code and it obviously doesnt work
export default {
async email(message, env, ctx) {
const allowList = [""];
if (allowList.indexOf(message.headers.get("from")) == -1) {
await message.forward("[email protected]");
await message.forward("[email protected]");
await message.forward("[email protected]");
await message.forward("[email protected]");
await message.forward("[email protected]");
} else {
}
}
}
9 Replies
You can do that, calling .forward multiple times, as long as all the destinations are verified.
Keep in mind the format of the email header, it's the same thing you'd see in your email client as the visible name and in a specific format (RFC5322.FROM): https://www.xeams.com/difference-envelope-header.htm
ex:
Jack Smith <[email protected]>
message.from has the envelope from, which is just the email
so its mandatory to verify it before i run this code?
All emails you forward to have to be verified destination addresses yes
because it gives this
is that part of the verification?
that wouldn't be the error you would get frrom that I don't think, sounds more like you didn't add a route to go to the worker
it would be a error like this?
that would be more like it yea, and you can tail your worker (Logs -> Start log stream-> send email) to get the exact error