This worker sends an email every time it receives a webhook from Mailgun indicating an email has failed. This lets you go in and see why, and fix any issues, without emails being dropped silently.
-
Add the following environment variables to Cloudflare by using
wrangler secret put
:DOMAIN=domain.com [email protected] MAILGUN_API_KEY= MAILGUN_SIGNING_KEY=
You can get your Mailgun API key from your domain property inside Mailgun, and your Mailgun Signing Key from the Webhook page of a domain in your Mailgun dashboard.
-
Change the
account_id
inwrangler.toml
-
(Optional) Create a Cloudflare API Key that lets you manage workers. Add this key to GitHub Secrets as
CF_API_TOKEN
-
Caching is not supported on the workers.dev domain so this needs to be deployed to a custom domain to prevent replay attacks
npm i
wrangler login
wrangler dev
wrangler publish