Send email using Workers with MailChannels
Can anyone guide me on how to debug the code shown in this blog https://blog.cloudflare.com/sending-email-from-workers-with-mailchannels/ ? I have a cloudflare page with the form, when I send it I get "Could not send your email. Please try again." HTTP error 512. No additional logs in the response. I am deploying this to my cloudflare page and testing there.
The Cloudflare Blog
Send email using Workers with MailChannels
MailChannels has created an email sending service specifically for Cloudflare Workers that removes all the friction associated with sending emails
5 Replies
Looks like this has been asked in the subreddit as well https://www.reddit.com/r/CloudFlare/comments/zg1ykh/mailchannels_pages_plugin_issues/
Reddit
From the CloudFlare community on Reddit: MailChannels Pages Plugin ...
Explore this post and more from the CloudFlare community
You need to add a domain lockdown record now to send from Mailchannels, that is the most likely source of that error.
You need to create the domain lockdown DNS record in the domain you want to send from, like
_mailchannels TXT v=mc1 cfid=xxxxx.pages.dev
where xxxx is your pages project.dev, like
_mailchannels TXT v=mc1 cfid=quick-test.pages.dev
Ref: https://community.cloudflare.com/t/introducing-mailchannels-domain-lockdown/523913?u=chaika
(Note: You use the pages.dev as the CFID if you are using Pages on a custom domain or the default pages.dev, it's the same for both)
You'd also want to set up SPF, and if wanting to follow best pratices, DKIM as well, both are detailed in the plugin guide:
https://developers.cloudflare.com/pages/platform/functions/plugins/mailchannels/#spf-support-for-mailchannels
Thank you! Will try these out
I would recommend avoiding MailChannels and using some other service like Amazon SES, Sendgrid, Postmark, etc.
There are a lot of security implications and their responses to the situation have been very undesirable. Further reading:
- https://github.com/byt3bl33d3r/SpamChannel
- https://byt3bl33d3r.substack.com/p/7fc21c89-4744-4a95-8095-cd080b498ded
- https://media.defcon.org/DEF%20CON%2031/DEF%20CON%2031%20presentations/byt3bl33d3r%20-%20SpamChannel%20Spoofing%20Emails%20From%202%20Million%20Domains%20and%20Virtually%20Becoming%20Satan.pdf
Thanks for the suggestion