π Update: We open-sourced this! Get AutoMail free at github.com/verygoodplugins/automail
Today while building the AutoMem.AI website, we needed a simple waitlist and email marketing system. The usual suspects (ConvertKit, Mailchimp, etc.) would’ve cost $20-50/month before we even had our first user. So we asked ourselves: can we build this for free?
Spoiler: Yes. And it runs entirely on Cloudflare’s free tier.
Better yet: We open-sourced it. You can grab the entire thing from GitHub and deploy it in 5 minutes.
π Get AutoMail (Free & Open Source)
We extracted this system into a standalone repo called AutoMail. It’s MIT licensed and ready to deploy:
git clone https://github.com/verygoodplugins/automail.git
cd automail
npm install
npm run db:create
# Edit wrangler.toml with your database ID
npm run db:migrate
npm run deploy
Done. Your waitlist is live. Zero cost. Full control.
The Problem with Traditional Email Marketing Tools
Don’t get me wrongβConvertKit and Mailchimp are great. But they’re overkill (and expensive) when you just need:
- A waitlist signup form
- Confirmation emails
- Welcome emails
- Occasional broadcasts
Most early-stage projects don’t need complex automation or analytics. They need something simple that just works.
Our Solution: Email Marketing at the Edge
Here’s what we built using only Cloudflare’s free tier:
The Stack
- Frontend: Astro component with client-side JavaScript
- Backend: Cloudflare Pages Functions (edge workers)
- Database: Cloudflare D1 (SQLite at the edge)
- Email Delivery: Resend API (3,000 free emails/month)
- Bot Protection: Cloudflare Turnstile (optional)
Features We Shipped
β
Email Validation: Client and server-side
β
Duplicate Prevention: No double signups
β
Double Opt-In: Optional email confirmation with secure tokens
β
Position Tracking: Shows users their waitlist position
β
Source Tracking: Know which page they signed up from
β
Admin API: Protected endpoints for JSON/CSV export
β
Broadcast Emails: Send to confirmed subscribers
β
Template Preview: Test emails before sending
β
Unsubscribe Links: HMAC-signed tokens that expire
β
Beautiful HTML Emails: With dark mode support
β
Bot Protection: Turnstile integration
How It Works
1. Signup Flow
User fills form β Turnstile verification β D1 database insert β Welcome email sent
The signup endpoint (/api/signup) runs as a Cloudflare Pages Function. It validates the email, checks for duplicates, stores it in D1, and optionally sends a confirmation or welcome email via Resend.
2. Database Schema (Simple!)
CREATE TABLE waitlist (
id INTEGER PRIMARY KEY AUTOINCREMENT,
email TEXT NOT NULL UNIQUE,
source TEXT DEFAULT 'website',
created_at TEXT NOT NULL,
confirmed BOOLEAN DEFAULT 0,
unsubscribed BOOLEAN DEFAULT 0,
metadata TEXT -- JSON for extra data
);
3. Email Templates
We built branded HTML email templates with:
- Dark mode support (
@media (prefers-color-scheme: dark)) - Mobile-responsive design
- On-brand styling (customizable for your project)
- Plain text fallbacks
Templates include: confirmation, welcome, and “Day 1” follow-up emails. All customizable in functions/lib/email.js.
4. Admin Endpoints
Token-protected endpoints for:
GET /admin/waitlistβ View all signups with stats (JSON)POST /admin/waitlistβ Export as CSVPOST /admin/broadcastβ Send campaigns (with dry-run mode)POST /admin/previewβ Preview email templates
5. Broadcasts
Need to send an update to your list? Simple cURL command:
curl -X POST https://your-site.com/admin/broadcast \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"template": "day1",
"confirmedOnly": true,
"dryRun": true # Preview first!
}'
The Cost Breakdown
| Service | Free Tier Limits | Monthly Cost |
|---|---|---|
| Cloudflare D1 | 100k reads/day, 1k writes/day | $0 |
| Pages Functions | 100k requests/day | $0 |
| Resend | 3,000 emails/month | $0 |
| Turnstile | Unlimited | $0 |
| Total | β | $0 |
Compare that to:
- ConvertKit: $25/month (1,000 subscribers)
- Mailchimp: $20/month (500 subscribers)
- Beehiiv: $49/month (basic plan)
Why This Matters
This approach is perfect for:
- Early-stage startups: Validate your idea before paying for tools
- Side projects: Keep costs at zero
- Simple use cases: Waitlists, launch announcements, basic updates
- Learning: Understand how email systems work under the hood
- Privacy-conscious builders: You own your data completely
You own your data, control your infrastructure, and pay nothing until you scale beyond the free tier (which is generous).
Trade-offs (Let’s Be Honest)
This isn’t perfect for everyone:
- No GUI: You interact via API/CLI, not a dashboard (though you could build one)
- Basic automation: No complex drip sequences or triggers out of the box
- No analytics dashboard: You’d need to build this yourself
- Requires dev knowledge: You need to be comfortable with code
But if you’re a developer building something new, those constraints are probably fine. And since it’s open source, you can extend it however you want.
Technical Highlights
Security Done Right
- HMAC-signed tokens: Confirm/unsubscribe links expire after 3 days
- Bearer token auth: Admin endpoints protected
- Turnstile verification: Optional bot protection
- Rate limiting: Via Cloudflare WAF (if needed)
Edge Performance
Everything runs at the edge on Cloudflare’s network:
- Pages Functions execute in <50ms globally
- D1 queries are fast (single-digit milliseconds)
- No cold starts (unlike AWS Lambda)
Background Jobs
Using Cloudflare’s waitUntil() API, we send emails in the background without blocking the response. Users get instant feedback, emails send asynchronously.
Getting Started with AutoMail
Full setup takes 5 minutes:
# Clone the repo
git clone https://github.com/verygoodplugins/automail.git
cd automail
# Install dependencies
npm install
# Create D1 database
npm run db:create
# (Note the database ID)
# Configure wrangler.toml with your database ID
cp wrangler.example.toml wrangler.toml
# Edit wrangler.toml
# Apply schema
npm run db:migrate
# Set admin token
npx wrangler secret put ADMIN_TOKEN
# (Enter a secure random string)
# Optional: Set Resend API key for emails
npx wrangler secret put RESEND_API_KEY
# Deploy
npm run deploy
That’s it! Check the README for detailed docs.
Lessons Learned
1. Free tiers are more generous than you think
Cloudflare’s free tier handles 100k reads/day on D1. That’s 3 million reads per month. For context, that’s enough for a waitlist with 10,000 active users checking their position multiple times daily.
2. Edge computing is fast
Our signup endpoint responds in <100ms globally. That’s faster than most SaaS APIs.
3. HTML emails aren’t that hard
With inline styles and simple layouts, you can build beautiful responsive emails in an afternoon. Dark mode support is just a media query.
4. You don’t need complex automation (yet)
Most early-stage projects need: signup β welcome email β occasional update. You can add complexity later.
5. Open sourcing creates value
By extracting and sharing this, we help other builders while building goodwill for AutoMem. Win-win.
What You Can Build With AutoMail
This isn’t just for waitlists. Use AutoMail for:
- Product launches
- Event registrations
- Newsletter signups
- Beta access waitlists
- Course enrollments
- Content gating
- Early bird discounts
Basically anything that needs: email signup β confirmation β occasional broadcasts.
Contributing & Roadmap
AutoMail is MIT licensed and welcomes contributions. Some ideas we’re considering:
- Simple analytics dashboard (views, clicks, unsubscribes)
- Scheduled broadcasts (using Cloudflare Cron Triggers)
- Segmentation by source or tags
- A/B testing for subject lines
- CLI tool:
npx create-automail
See something missing? Open an issue or PR on GitHub.
Final Thoughts
Building your own email system isn’t for everyone. ConvertKit and Mailchimp are great products with excellent UX and powerful features.
But if you’re a developer who wants:
- Complete control
- Zero costs
- Fast performance
- Simple requirements
- No vendor lock-in
…then AutoMail on Cloudflare’s free tier is perfect.
We built this in a day. It costs us exactly $0. And now it’s yours too.
Questions? Found this helpful? Star the repo, open an issue, or reach out on Twitter/X.
Building something with AutoMail? We’d love to hear about it!
β Jack
