Back to blog
Automated Newsletter Broadcasting with Cloudflare Workers
2 min read
cloudflare newsletter automation typescript
I just finished building an automated newsletter system for this site. Here’s how it works! 🎉
The Problem
Having a newsletter subscription system is great, but manually sending emails every time I publish something? That’s a recipe for forgetting and inconsistency.
I wanted:
- Automatic blog notifications — When I publish a new post, subscribers get notified
- Weekly TIL digest — A compilation of everything I learned that week, sent every Sunday
The Solution
The system uses Cloudflare Workers cron triggers to periodically check for new content:
Blog Post Notifications
Every day at 10am UTC, a cron job:
- Fetches all published blog posts
- Checks which ones haven’t been emailed yet (tracked in D1 database)
- Sends personalized emails to all active subscribers
- Records what was sent to avoid duplicates
Weekly TIL Digest
Every Sunday at 10am UTC:
- Collects all TILs from the past week
- Compiles them into a single digest email
- Sends to all subscribers
Technical Stack
- Cloudflare Workers — Serverless compute for cron jobs
- Cloudflare D1 — SQLite database for subscriber management and sent tracking
- AWS SES — Reliable email delivery with proper authentication
- Astro — Static site generation with server-side API routes
The Email Templates
Each email includes:
- Beautiful HTML version (matching the site’s green garden theme)
- Plain text fallback
- One-click unsubscribe link (RFC 8058 compliant)
- List-Unsubscribe headers for email client support
Good question! Right now it’s all-or-nothing, but granular preferences are on the roadmap. For now, you can always unsubscribe and re-subscribe when you see a post you’re interested in.
What’s Next?
- Granular subscription preferences (blog only, TIL only, etc.)
- Preview emails before sending (admin dashboard)
- Email open/click tracking (privacy-respecting)
If you haven’t already, subscribe below to see the system in action! 🌱