email not being blocked
Hello I am trying to block a certain email for testing and i am still recieving it.
19 Replies
Hey 👋
You're getting the from header -- which is in a specific format RFC 5322.
It could be just the email like that, but most email clients also include a name, something like
Jack Smith <[email protected]>
https://www.xeams.com/difference-envelope-header.htmoh
how would I get the email then
You could parse it out. There's various parsing libraries out there
There's also the
from
on the message message.from
, "envelope from', but that's very easy to spoof and not visible to the end user, can be very different in some cases.
End users (like in gmail/etc) only see the header from, the one you're using
If you're doing something simple and don't need it to be too robust, you could just do message.headers.get('from').endsWith('<[email protected]>')
. With a list you could do that in .some()ty ill try that
Hm, that still goes through to my email
The format is surrounded by brackets if there's a display name
can always log and tail too
console.log(message.headers.get('from'))
console.logs arent being printed out
You're tailing and not seeing them, o r?
yes
Do you see the email event?
yesd
Using dashboard or wrangler tail? If you're using dashboard make sure you're expanding
dashboard, I just see "ok" in the console
click on it to expand?
nice, logs!
well you can see the format there
alright thanks ill try that
there is proper parsing libraries you can use too, like https://github.com/jackbearheart/email-addresses. If you wanted to do it the "right way", haven't tried that package before with Workers but it doesn't look like it has any node deps
I managed to figure it out by doing this
Thanks ill take a look at those