"Could not send your email. Please try again." with MailChannels Pages Plugin
I m trying to send emails from a form in a astro static site I m making but I couldn't find a way to make it work.
I followed the guide https://developers.cloudflare.com/pages/functions/plugins/mailchannels/#spf-support-for-mailchannels
Right now I m not using cloudflare email routing as I m using google workspace, but I suppose it should work anyway, correct?
- So i created the
_middleware.ts
file (code on first comment), having "@cloudflare/pages-plugin-mailchannels": "^0.1.2"
on the dependencies
- On the form I added the attribute data-static-form-name="contact"
- Added includes to my existing spf record so now look like this v=spf1 include:_spf.mx.cloudflare.net include:relay.mailchannels.net include:_spf.google.com -all
- Generated DKIM Credentials following the guide https://developers.cloudflare.com/pages/functions/plugins/mailchannels/#generate-dkim-credentials
- Added to environment variables (see image)
- Added the TXT record mailchannels._domainkey (see image)
- Added domain lockdown (TXT _mailchannels
) with both workers domain and my domain as stated here https://community.cloudflare.com/t/introducing-mailchannels-domain-lockdown/523913/5: v=mc1 cfid=majestico.workers.dev cfid=majestico.it
(and see image)
Now when i try to send email from https://majestico.it/contact/ I get the error "Could not send your email. Please try again."
Am I missing something?
Is there a way to debug this problem and get a significant error?
ThanksMailChannels · Cloudflare Pages docs
The MailChannels Pages Plugin intercepts all form submissions made which have the data-static-form-name attribute set. Then, it emails these form …
5 Replies
You're mentioning https://majestico.it/contact/, and the record for
majestico.it
is pointing towards majestico-it.pages.dev
.
Considering that set up, it seems to me like you're missing cfid=majestico-it.pages.dev
in your MailChannels Domain Lockdown record.Thanks @DarkDeviL it was actually that
Hey there! So I am completely new to cloudflare and mailchannels. I read the documentations and watched some videos on workers. I configured my DNS records. I didn't see anything in the mailchannels documentation if I need to edit the wrangler.toml file and setting up routes. I am getting this error when I deployed my sample worker for the email.
Sorry to bring up an old post. I was searching around before asking and found your post so I compared my setup