Mailchannels Issues

Hello. I have tried everything I can and still cannot get mail channels to work. I am not exactly sure what to do anymore at this point. I followed the mail channels plugin from this documentation https://developers.cloudflare.com/pages/functions/plugins/mailchannels/ What I've done: Set up DNS records Set up my DKIM Keys Created environment variables from my DKIM keys I also saw this post https://rivenintech.com/blog/free-contact-form-cf-pages-mailchannels It seems to be pretty simple using pages functions instead of creating workers. I have tried doing the workers route but I am not sure if I was setting it up properly and pages functions seems to be pretty straightforward. I just need a simple contact form to forward to an email domain that's using google workspaces. I am new to cloudflare and I am more of a database developer. I have been stuck on this for 4 days and been doing a ton of research but still no luck. Thank you for any assistance.
Cloudflare Docs
MailChannels · 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 …
Free Contact Form with Cloudflare Pages & MailChannels
Are you hosting your website on Cloudflare Pages? In this article, I'll show you how to create a free contact form using Cloudflare Workers and MailChannels.
No description
No description
49 Replies
MylesBolton
MylesBolton8mo ago
domain should just be bbybloom.co not a email allso plz give error logs
lckillah
lckillahOP8mo ago
Hello. When I try to go to the error log according to this documentation https://developers.cloudflare.com/pages/functions/debugging-and-logging/#view-logs-in-the-cloudflare-dashboard I get an error saying "We could not find that Workers Service on your account. (Code: 8000068)" I didn't see anything about setting up a worker for error log. Do I have to do that it seems?
Cloudflare Docs
Debugging and logging · Cloudflare Pages docs
Access your Functions logs by using the Cloudflare dashboard or the Wrangler CLI.
No description
MylesBolton
MylesBolton8mo ago
do you have a add blocker or something on ?
Chaika
Chaika8mo ago
Do you have Smart Placement enabled on your Pages Project? For your mailchannels record, your cfid should be your pages.dev, ex: bbybloom.pages.dev in this case it looks like Also that dkim private key, should well, be private/a secret, should roll it now that you've exposed it There's also reasons why you might want to avoid mailchannels: https://discord.com/channels/595317990191398933/779390076219686943/1152689451374477483
MylesBolton
MylesBolton8mo ago
you sure ? ive been having made problems with this all day
Chaika
Chaika8mo ago
Yep, their cfid is from the CF-Worker header it'd only be workers.dev if you were calling the mailchannels api from a worker on its workers.dev for Pages, it'll always be the pages.dev for the project, even for Pages Projects invoked via Custom Domains. For Workers on Custom domains, it'd be your zone's name.
lckillah
lckillahOP8mo ago
I don't think so. I am going to completely redo everything and start the set up. For workers, does it matter what type of worker I create on wrangler or just pick "hello world" worker?
MylesBolton
MylesBolton8mo ago
so i have a pages setup with a custom domain thsi is probably the problem i have been having
Chaika
Chaika8mo ago
Are you using Workers or Pages?
MylesBolton
MylesBolton8mo ago
pages
Chaika
Chaika8mo ago
Talking to ICKillah, the screenshots he showed were all Pages, and then he mentions creating a worker
MylesBolton
MylesBolton8mo ago
maybe he has the function running on the pages plugin
lckillah
lckillahOP8mo ago
I tried both. I was trying to just go with "Functions" with pages since that it might be easier for my use case since I only want a simple email from a contact form. I saw it from this guide https://rivenintech.com/blog/free-contact-form-cf-pages-mailchannels
Free Contact Form with Cloudflare Pages & MailChannels
Are you hosting your website on Cloudflare Pages? In this article, I'll show you how to create a free contact form using Cloudflare Workers and MailChannels.
Chaika
Chaika8mo ago
well before you go changing everything, I would at least try changing your mailchannels record to v=mc1 cfid=bbybloom.pages.dev cfid=bbybloom.co and double checking under your Pages Project -> Settings -> Functions -> Placement, you don't have Smart Placement enabled. That can mess with tail
lckillah
lckillahOP8mo ago
Ok will do. I do have to recreate the worker though because I was kind of confused to how I was going to set it up and I thought functions for pages would be better so I don't have to create a worker Yes I have the default placement. Will set it to smart
Chaika
Chaika8mo ago
nono keep default lol smart placement can cause issues with tail
lckillah
lckillahOP8mo ago
Oh I meant you said to enable it haha
Chaika
Chaika8mo ago
So the cfid is from the CF-Worker Header. The Cf-Worker Header is set like this:
Worker: If it's ran via your workers.dev, it's yourworkersubdomain.workers.dev Worker: If it's ran via route or custom domain, it's the zone/website name (may be a subdomain if using partial setup) Function: If it's a Pages Function, it's always the projectname.pages.dev even if called via a Custom Domain Worker: If it's something that runs without an http request, like crons, queues, etc, it's your workers.dev
docs: https://developers.cloudflare.com/fundamentals/reference/http-request-headers/#cf-worker
lckillah
lckillahOP8mo ago
Got it. Awesome will review and make these changes later as soon as I get the chance and will report back. I have to start my day job for the time being haha. Thank you! Would you recommend going the functions instead of creating a worker for the email?
Chaika
Chaika8mo ago
Someone else was reporting issues with mailchannels and CF in general yesterday: https://discord.com/channels/595317990191398933/779390076219686943/1226423746575859773 so getting proper logs would be helpful as well. I'll try to remember to test it sometime later as well, might not be purely a config issue whatever's easier if the pages tutorial seemed easier/had what you wanted, I would go with that just have to make sure to include your pages.dev in the allowed cfids for sending
lckillah
lckillahOP8mo ago
I made sure to turn off my adguard and still getting We could not find that Workers Service on your account. (Code: 8000068) when I click begin stream on the dashboard for the debug...
Chaika
Chaika8mo ago
if you go under the latest Deployment functions tab, do you see any functions being deployed?
lckillah
lckillahOP8mo ago
In this tab?
No description
Chaika
Chaika8mo ago
well, the Build Logs for that deployment should show something like:
01:37:29.832 Found Functions directory at /functions. Uploading. 01:37:30.846 ✨ Compiled Worker successfully or Note: No functions dir at /functions found. Skipping.
, or at the bottom of that tab, you should have a "Invocation routes" showing any middleware/etc How are you uploading the pages deployment? Via drag & drop in the dashboard?
lckillah
lckillahOP8mo ago
Hey Chaika. Via drag and drop. Just now getting to this
Chaika
Chaika8mo ago
Drag and Drop doesn't support functions. Have to use wrangler (wrangler pages deploy) or more preferability make a Pages Project connected to a Github repo and gain Pages Builds CI/CD
lckillah
lckillahOP8mo ago
Oh that makes a lot of sense then. I'll try to deploy using either of those and will report back. I'd rather use the page functions so I'll give that a try
lckillah
lckillahOP8mo ago
I have been troubleshooting this for 5 hours straight and have tried everything. I rebuilt my wrangler.toml and put my functions inside ./functions folder. Whenever I run wrangler deploy, I get this message: Missing entry-point: The entry-point should be specified via the command line (e.g. wrangler deploy path/to/script) or the main config field. I uninstalled and reinstalled wrangler to make sure it's on the latest version. My wrangler.toml settings is attached and my page structure as well. Any pointers as what could possibly be going wring?
No description
No description
No description
Chaika
Chaika8mo ago
wrangler deploy is for Workers, it's looking for a script. wrangler pages deploy is for pages.
lckillah
lckillahOP8mo ago
Dang I can't believe that's what I was missing. Thanks! Now to troubleshoot why the contact form still isn't sending lol
lckillah
lckillahOP8mo ago
Ok now I am getting somewhere. At least I get a reponse now. I used the setup according to the mailchannels pages plugin documentation https://developers.cloudflare.com/pages/functions/plugins/mailchannels/#:~:text=The%20MailChannels%20Pages%20Plugin%20intercepts,submissions%20using%20the%20MailChannels%20API. my domain lockdown records are: _mailchannels v=mc1 cfid=bbybloom.co cfid=bbybloom.pages.dev my spf records are: v=spf1 include:dc-aa8e722993._spfm.bbybloom.co include:relay.mailchannels.net -all this part of my spf records include:dc-aa8e722993._spfm.bbybloom.co was already there when I traansferred my domain. It was prefilled. At least the debugging is responding now but I am getting the attached error.
Cloudflare Docs
MailChannels · 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 …
No description
No description
lckillah
lckillahOP8mo ago
Also gonna add, I am using google workspaces custom email that is set up through my domain godaddy. Not sure if that adds anything to the equation.
Chaika
Chaika8mo ago
what's the pages plugin settings you specified/what from address?
lckillah
lckillahOP8mo ago
I actually got it to work now! The private key weren't matching because when I first started reading documentations, it says to generate private key. And since I am new to this, I thought I can just run it using terminal. Turns our everything has to be ran from your projects. Thank you SOOOO much for the help! You were a tremendous help.
lckillah
lckillahOP8mo ago
Actually, one more question. So I got it to work using the pages function (by creating a simple html contact file and then putting my _middleware.ts inside the functions folder). But I want to capture my contact form and put the email of the form in the reply to and possibly the name in the subject field. I saw this static form plugin but not sure if that's what I need for my use case https://developers.cloudflare.com/pages/functions/plugins/static-forms/
Cloudflare Docs
Static Forms · Cloudflare Pages docs
The Static Forms Pages Plugin intercepts all form submissions made which have the data-static-form-name attribute set. This allows you to take action …
Chaika
Chaika8mo ago
mailchannels plugin uses the static form plugin under the hood. You could use it to grab all the form data and do the fetch request to mailchannels or any other email provider in your own code
lckillah
lckillahOP8mo ago
Oh so I have to create a worker then with fetch after all?
Chaika
Chaika8mo ago
no, you can do all that in functions Functions are Workers, just with some sugar/magic on top like file based routing, middleware, versioning, etc
lckillah
lckillahOP8mo ago
ohhhh gotcha. Still new to this so thank you for your patience and your help! Gonna find and read some documentations about static form plugin and see what I can do looking at the static forms documentation, the script looks very similar to mailchannels plugin import staticFormsPlugin from "@cloudflare/pages-plugin-static-forms"; export const onRequest: PagesFunction = staticFormsPlugin({ respondWith: ({ formData, name }) => { const email = formData.get('email') return new Response(Hello, ${email}! Thank you for submitting the ${name} form.) } }); I can probably just use that to combine with my _middleware.ts and don't have to import the staticFormsPlugin since it uses the same thing right?
dakom
dakom8mo ago
Haven't reviewed all the previous discussion here, forgive me if this has already been asked/answered - but how do I setup domain locking for a worker (and pages) that does not have a custom domain? i.e. I'm just using the provided foo-xyz.pages.dev and my.example.workers.dev
lckillah
lckillahOP8mo ago
Still new to this and have read a lot of documentations so bear with me if I give you the wrong information. From my understanding, you need to have a domain to use mailchannels API. I think it's because email servers check for the domain. Again, not sure. But have you tested it and tried it out? The documentations that I've read says you need to have a domain but I could be wrong
dakom
dakom8mo ago
Yeah, I am getting the impression that you might be right :/ Yes, from just trying it as-is I get the domain locking error
tornado
tornado5mo ago
Were the docs for mail channels removed? I can't find them
Chaika
Chaika5mo ago
yup mailchannels killed the partnership, not a big loss though. There's a few other options and more info here: https://community.cloudflare.com/t/mailchannels-end-of-life-notice-migrate-now/658638?u=chaika
tornado
tornado5mo ago
So I had a website using mail channels, will that stop working suddenly? It was working last time I checked few days ago
Chaika
Chaika5mo ago
yes, as of June 30th the api is rejecting mail from workers
tornado
tornado5mo ago
Interesting, had emails delivered on July 9th
Chaika
Chaika5mo ago
there's other options like postmark or resend, or any other mail service with an http api you can use within workers https://developers.cloudflare.com/workers/tutorials/send-emails-with-postmark/ https://developers.cloudflare.com/workers/tutorials/send-emails-with-resend/ weird, I haven't tried it after their date, just trusting what they said on the page. Mailchannels isn't really a recommendable provider eitherway with the amount of security issues they had: https://discord.com/channels/595317990191398933/779390076219686943/1226529017763463219
tornado
tornado5mo ago
Which one would be the best for send to a list of emails/broadcast at once (but keeping the list hidden from recipients) like a newsletter. Or is just using bcc the preferred approach?
Want results from more Discord servers?
Add your server