How I Spent a Night Fighting Mailchannels and Fixed It With Resend in 10 Minutes
Sometimes the simplest tasks turn into the biggest time sinks. Here's how adding a contact form to my website became an all‑night battle with Cloudflare Workers, a stubborn 401 error, and how Resend saved the day.
The Mission
I'm a self‑taught Flutter developer with a background in banking. I have a personal portfolio site where I showcase my apps, and I wanted a contact form that would actually send emails to my inbox. Simple, right?
I already had Cloudflare set up, so the natural choice was to use Cloudflare Workers with Mailchannels — a "free and easy" solution everyone talks about.
The Struggle With Mailchannels
I wrote the Worker, added the form, tested it… and got hit with a 401 Authorization Required. Cue the rabbit hole.
What I Tried (and Failed)
- Added SPF records — checked
- Added
_mailchannelsDomain Lockdown TXT record — checked - Added DKIM keys — checked
- Disabled, enabled, re‑added DNS records — checked, checked, checked
Every time — 401. Logs showed Mailchannels simply refused to authorize my domain. I spent hours reading docs, tweaking DNS, waiting for propagation, redeploying Workers. Nothing worked.
The Breaking Point
It was 2 AM. I had a working form that validated input, checked Turnstile, and beautifully formatted emails — but they never reached my inbox. I was about to give up and rip the whole thing out.
Then the AI assistant (shoutout to the Cloudflare‑helper) finally said:
"Enough with this Mailchannels nonsense — try Resend."
Resend: 10 Minutes to Victory
I signed up on resend.com — no credit card, just email confirmation. Then:
- Added my domain — copied a few DNS records (TXT, MX, DKIM) into Cloudflare.
- Verified — clicked "Verify", everything turned green in 2 minutes.
- Generated an API key — named it "Fonsalus Contact", set permissions to "Sending access" only.
- Updated my Worker — swapped out the Mailchannels fetch for a simple POST to Resend's API.
Here's the code that now powers my contact form:
// contact-form-email-worker
export default {
async fetch(request, env) {
const { to, subject, html, text } = await request.json();
const response = await fetch('https://api.resend.com/emails', {
method: 'POST',
headers: {
'Authorization': `Bearer ${env.RESEND_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
from: 'send@fonsalus.com',
to: [to],
subject: subject,
html: html,
text: text,
}),
});
const result = await response.json();
return new Response(JSON.stringify({ success: response.ok, result }));
}
}
I deployed it, clicked "Send" on my form, and before I could blink — the email was in my inbox. No delay, no spam folder, no hassle.
What I Learned
- Mailchannels can work, but the setup is finicky and support is minimal. For a production form, it's a gamble.
- Resend just works. Clear docs, instant domain verification, and an API that feels like it was built for developers who want to ship, not troubleshoot.
- Sometimes the "standard" path isn't the best. Don't be afraid to pivot when something feels broken.
Shoutout to the Team
After I signed up, I got a welcome email from Zeno, the founder & CEO of Resend. I replied with my story (the one you're reading now), and he actually wrote back:
"This made my day. Really appreciate you taking the time to share this. There's nothing better than hearing that something that took us years to build only took you 10 minutes to use. That's exactly what we're going for."
— Zeno, CEO of Resend
That's the kind of company I want to build with.
Try It Yourself
If you're struggling with email delivery from Cloudflare Workers, save yourself the headache:
- 👉 Sign up for Resend (free tier: 3,000 emails/month)
- 👉 Read their Cloudflare Workers guide
And if you ever get stuck, their support actually replies — I know, because I tested it.
Ilja is a former banking executive turned Flutter developer. He builds offline‑first apps for professionals and occasionally blogs about the struggles of learning to code mid‑career. You can find him on LinkedIn or check out his apps: Elektriku Treener and Personality Compass.