Paperboy is a small Cloudflare Worker for sites with an RSS feed. When you publish a new post, it creates an email broadcast for it in Resend, and Resend sends it to your subscribers. I use it on my blog, ayonkhan.ca.
Once an hour by default, it reads your feed. If the newest post is one it hasn't seen yet, it fills in the email template and creates a broadcast in Resend, scheduled two hours later by default. That gives you time to review the scheduled broadcast in Resend, and cancel it if something looks wrong. Paperboy doesn't check the email itself.
I built it for my Hugo blog, which uses the PaperMod theme, but it works with any site that has an RSS feed, whatever it's built with. It reads the live feed instead of watching your site's repo, and skips posts dated in the future, so a scheduled post isn't emailed before its date. The email template is simple, so you may want to change it to match your site. See Customize.
Paperboy only creates the broadcasts. It doesn't collect subscribers, so you'll need some way of adding them to a segment in Resend: a subscription form, an import or adding them by hand. On my blog, that's PaperMod Subscribe, a subscription form for Hugo sites using PaperMod.
- How It Works
- Limitations
- Requirements
- Setup
- Keep Your Feed Short
- Customize
- Run Locally
- Check on It
- Troubleshooting
- Tests
- License
src/index.jsreads the feed, finds the newest post by its date, wherever it is in the feed, compares it with the last one it created a broadcast for, and creates the broadcast.templates/new-post.mjmlis the email template, written in MJML. It's compiled to HTML on every build. Placeholders use%%name%%, so they don't clash with Resend's{{{...}}}placeholders.- Cloudflare KV (
SENT_POSTS) remembers the last post it created a broadcast for. On the very first run, it only records the newest post without creating a broadcast, so turning it on doesn't email an old post to everyone.
- One post per check. Each run creates a broadcast for the newest post only. If you publish two posts between checks, only the newer one gets a broadcast, and the older one is skipped. Checks run once an hour by default, set by
cronsinwrangler.toml. Leave at least that long between posts if you want an email for each. - Backdated posts are skipped. A post only counts as new if it has the newest date in the feed. If you publish a post with a date older than your latest post, it isn't emailed. Set the date to the day you publish it.
- One try per post. A post is marked as done once Resend accepts the broadcast. If you cancel the scheduled broadcast in Resend, or it fails later, Paperboy won't try again. To send it anyway, create a broadcast for it in Resend yourself.
- RSS 2.0 only. Atom feeds aren't supported.
- A Cloudflare account, for the Worker and KV
- A Resend account with a verified domain
- An RSS 2.0 feed (Atom feeds aren't supported)
- Node.js, only to deploy from your computer or run it locally
Here's how the pieces fit together:
- Resend sends the emails. You'll need three things from it: a sending domain, a segment of subscribers and an API key.
- Cloudflare runs Paperboy on a schedule, once an hour by default, and keeps track of the last post it created a broadcast for in a KV namespace.
- The settings tell Paperboy where your feed is, who to email and how to reach Resend.
Setup takes three steps:
- Set up Resend
- Deploy Paperboy, in one of two ways
- Fill in the settings
You'll use three things from Resend when you fill in the settings, so keep them handy:
- Your sending domain. Add and verify it under Domains. Resend recommends a subdomain, such as
news.example.com. Your sender address goes on this domain, and becomesFROM_EMAIL. - A segment ID. Under Audience, create a segment for subscribers, and copy its ID. This becomes
SEGMENT_ID. - An API key. Under API Keys, create a key with Full access, and copy it. Paperboy creates broadcasts, and a key with only sending access can't do that. Resend only shows it once. This becomes
RESEND_API_KEY.
Choose one way:
- A. From a repo: Cloudflare deploys Paperboy from GitHub or GitLab every time you push to
main. - B. From your computer: you deploy it yourself, by running
npm run deploy.
Each option needs a KV namespace, where Paperboy remembers the last post it created a broadcast for. The steps link to Create the KV Namespace when it's time.
- Put Paperboy in your own repo: fork this one, or copy it to a new repo on GitHub or GitLab.
- Create the KV namespace, put its ID in your repo's
wrangler.toml, and commit the change. - Connect the repo to Cloudflare.
Then continue with Fill In the Settings.
You'll need Node.js.
-
Download or clone this repo, and open a terminal in its folder.
-
Install the dependencies:
npm ci
-
Log Wrangler in to your Cloudflare account:
npx wrangler login
-
Create the KV namespace, and put its ID in
wrangler.toml. -
Deploy. This compiles the email template and creates the Worker on Cloudflare:
npm run deploy
Run it again whenever you change something.
Then continue with Fill In the Settings.
In Cloudflare, go to Storage & Databases > KV, create a namespace called SENT_POSTS, and copy its ID.
Or, if you've logged Wrangler in, from the terminal:
npx wrangler kv namespace create SENT_POSTSIt prints the ID.
Then, in wrangler.toml, replace the id under [[kv_namespaces]] with yours:
[[kv_namespaces]]
binding = "SENT_POSTS"
id = "your-namespace-id"Go back to the option you were following.
- In Cloudflare, go to Workers & Pages, click Create, and choose to import a repository.
- Connect your GitHub or GitLab account, and choose your repo.
- Keep the name
paperboy, so it matchesnameinwrangler.toml. - Set the build command to
npm run build, and the deploy command tonpx wrangler deploy. - Deploy.
From then on, every push to main deploys Paperboy.
Go back to the option you were following.
In Cloudflare, go to Workers & Pages > paperboy > Settings > Variables and Secrets, and add these as Text variables:
| Setting | Example | What it's for |
|---|---|---|
SITE_NAME |
example.com |
Shown at the top and bottom of the email |
SITE_URL |
https://example.com/ |
Where the site name links to |
FEED_URL |
https://example.com/index.xml |
Your RSS feed |
FROM_EMAIL |
Your Name <blog@news.example.com> |
The sender, on the domain you verified in Resend |
REPLY_TO |
hello@example.com |
Where replies go (optional) |
SEGMENT_ID |
the segment ID from Resend | Who gets the email |
TIME_ZONE |
America/Regina |
Used for the post date in the email (optional, defaults to UTC) |
DATE_LOCALE |
en-US |
How the date is written (optional, defaults to en-GB, as in "7 November 2026") |
SEND_DELAY_HOURS |
2 |
How long to wait before sending, so you can check the email first (optional, defaults to 2; use 0 to send right away) |
MAILING_ADDRESS |
123 Example Street, Example City, Country |
A mailing address for the email's footer, which some anti-spam laws require in commercial emails (optional) |
Then add the API key from Resend as a Secret in the same place, named RESEND_API_KEY. If you deployed from your computer, you can set it from the terminal instead:
npx wrangler secret put RESEND_API_KEYIt asks you to paste the key, and stores it encrypted.
Some anti-spam laws require a mailing address in commercial emails. If yours need one, set MAILING_ADDRESS, and it appears in the footer, just above the unsubscribe link.
keep_vars = true in wrangler.toml makes deploys leave these settings alone. If you'd rather keep your settings in the repo, remove keep_vars and fill in the commented [vars] section in wrangler.toml instead.
That's it. Paperboy now checks your feed on its schedule, at the start of every hour by default. The first run only records your newest post, so the first email goes out with your next post. If an hourly run happens before you've added the settings, it stops with a Missing settings error, which is harmless.
Paperboy only needs the newest post, but it downloads and reads the whole feed on every run. On Cloudflare's free plan, each run gets 10 ms of CPU time, so a smaller feed leaves more room. Many sites list every post in their feed by default. If you don't post often, limiting it to the newest 20 or so is usually plenty. Feed readers use your feed too, so choose a limit that still covers the posts they might not have seen yet.
On Hugo, for example, add this to your site's config:
services:
rss:
limit: 20You can see how much CPU time each run uses under Workers & Pages > paperboy > Metrics.
- The email: edit
templates/new-post.mjml. The placeholders you can use are%%title%%,%%description%%,%%link%%,%%date%%,%%site_name%%,%%site_url%%and%%mailing_address%%. Keep{{{RESEND_UNSUBSCRIBE_URL}}}, since Resend needs it for the unsubscribe link. - The subject: it's set in
src/index.js, as'New post: ' + post.title. - How often it checks: change
cronsinwrangler.toml.
Running locally means running Paperboy on your own computer, without deploying it. It's for trying out changes, such as a new email template, before they reach Cloudflare and your subscribers. That's different from option B, which deploys Paperboy to Cloudflare, where it runs every hour on its own.
You'll need a copy of this repo with the dependencies installed and Wrangler logged in, as in steps 1 to 3 of option B.
A local run can't see the settings you added in Cloudflare in Fill In the Settings, so it needs its own copy, in a .dev.vars file in the project folder. Start from the example:
cp .dev.vars.example .dev.varsThen fill it in. .dev.vars is in .gitignore, so it never gets committed. Local runs send real emails through Resend, using your real API key. Use a test segment with only your own address in it as SEGMENT_ID, so you don't email your subscribers by accident.
If a setting is missing, the run stops with an error naming it, such as Missing settings: FEED_URL.
Locally, KV starts empty, so the first run would only record the newest post. To make the newest post count as new, pretend an older post was the last one with a broadcast:
npx wrangler kv key put last-sent "https://example.com/posts/old/" --binding SENT_POSTS --localStart the Worker. This also compiles the template, and lets you trigger the hourly job yourself:
npm run devThen, in a second terminal tab, trigger a run:
curl "http://localhost:8787/__scheduled?cron=0+*+*+*+*"A new broadcast shows up in Resend under Broadcasts, scheduled to send after the delay set by SEND_DELAY_HOURS, two hours by default. Run the same command again, and nothing new should appear, since Paperboy now remembers that post. When you're done, unschedule or delete the test broadcast in Resend.
To see the last post Paperboy created a broadcast for:
npx wrangler kv key get last-sent --binding SENT_POSTS --remoteIf a run fails, for example because Resend rejects the broadcast, the error shows up under Workers & Pages > paperboy > Observability.
A new post wasn't emailed.
- On the very first run, Paperboy only records the newest post. The next new post is the first one to get a broadcast.
- The post has to be in your live RSS feed, with the newest date. Open
FEED_URLin a browser and check its<pubDate>. - If you published two posts between checks, only the newer one gets a broadcast. See Limitations.
- Check the broadcast in Resend under Broadcasts. It's scheduled to send after
SEND_DELAY_HOURS, two hours by default.
A run failed. The error shows up under Workers & Pages > paperboy > Observability.
Missing settings: ...names the settings to add under Settings > Variables and Secrets.Resend returned 4xxusually meansFROM_EMAILisn't on a verified domain,SEGMENT_IDis wrong, or the API key doesn't have full access.Exceeded CPU time limitmeans the feed is too big for the free plan. See Keep Your Feed Short.
Nothing happens at all. Paperboy only reads RSS 2.0 feeds, with <item> entries. Atom feeds, with <entry>, aren't supported.
The Worker has automated tests, which run on GitHub every time code is pushed. They use a fake feed and a fake Resend, so they don't need any accounts. To run them yourself:
npm testThis compiles the email template, then runs the tests.