woulduno
04/22/2023, 3:02 AMChaika
04/22/2023, 3:15 AMwrangler tail
or go to the worker in the dashboard, and then Logs -> Start Log Stream, then send an email. It should show the failure and you can expand it to see the errorwoulduno
04/22/2023, 3:20 AMChaika
04/22/2023, 3:28 AMif (allowList.indexOf(message.headers.get("from")) == -1) {
to
if (allowList.indexOf(message.from) == -1) {
(just changing message.headers.get("from") to message.from)
Does that work?
The different is the message.from is the envelope FROM rather then the header
I haven't used that template before, but my understanding is the header from is the "friendly" version of the header and includes sender name and such, envelope only includes the actual sender address
ex.
"From header: \"Chaika\" "
"From envelope: chaika@chaika.dev"woulduno
04/22/2023, 3:32 AMwoulduno
04/22/2023, 3:32 AMChaika
04/22/2023, 3:37 AMif (message.from.endsWith("@domain.com") == false) {
woulduno
04/22/2023, 3:38 AMwoulduno
04/22/2023, 3:38 AMChaika
04/22/2023, 3:42 AMexport default {
async email(message, env, ctx) {
const allowList = ["chaika@example.org"];
const allowDomainList = ["@example.com"]
if (allowList.indexOf(message.from) == -1 && allowDomainList.some(domain => message.from.endsWith(domain)) == false) {
message.setReject(`Address not allowed from: ${message.from}`);
} else {
await message.forward("inbox@corp");
}
}
}
Fwiw, I believe FROM Addresses can be spoofed to some extent, although I believe that comes down to the security the sending domain has setupwoulduno
04/22/2023, 3:44 AMwoulduno
04/22/2023, 3:45 AM