Skip to content

jackson2w/claude-code-skills / cloudflare-workers-cron-email

cloudflare-workers-cron-email

Verified

This skill should be used when the user asks to debug a Cloudflare Workers Cron Trigger that "isn't firing" or "not running" (or fires on the wrong day), set up or troubleshoot the send_email binding or Email Routing destination addresses for Workers, size a Worker against Cloudflare's per-invocation subrequest limits, test a scheduled() handler locally against real R2/KV/email bindings, verify an R2 delete/rename actually took effect, or rename/reorganize keys in an R2 bucket. Trigger phrases include "cron trigger not firing", "scheduled worker not running", "cron ran on the wrong day", "wrangler cron", "cron trigger debug", "send_email binding", "Workers email binding", "Email Routing destination address", "workers subrequest limit", "test-scheduled --remote", "r2 object rename", "r2 delete not working", "r2 move objects".

FileKindSize
SKILL.mdskill md12.1 KB
references/diagnosing-cron.mdmarkdown4.6 KB
references/email-binding.mdmarkdown4.4 KB
scripts/check-cron-invocations.shexecutablescript1.9 KB
scripts/check-schedule-registered.shexecutablescript586 B

references/email-binding.md

View on GitHub
# `send_email` binding: config and API reference

## wrangler.toml / wrangler.jsonc syntax

```toml
[[send_email]]
name = "EMAIL"
# No destination_address: binding can send to any verified destination
# address in the account.

[[send_email]]
name = "NOTIFY_OPS"
destination_address = "ops@yourdomain.com"
# Restricts this binding to a single fixed recipient — a good safety rail
# for a single-purpose notification Worker.

[[send_email]]
name = "EMAIL_TEAM"
allowed_destination_addresses = [ "alice@yourdomain.com", "bob@yourdomain.com" ]
# Allowlist of permitted recipients.

[[send_email]]
name = "RESTRICTED_EMAIL"
allowed_sender_addresses = [ "noreply@yourdomain.com", "support@yourdomain.com" ]
# Allowlist of permitted senders.
```

JSONC equivalent:

```jsonc
{
  "send_email": [
    { "name": "EMAIL" },
    { "name": "NOTIFY_OPS", "destination_address": "ops@yourdomain.com" },
    { "name": "EMAIL_TEAM", "allowed_destination_addresses": ["alice@yourdomain.com", "bob@yourdomain.com"] },
    { "name": "RESTRICTED_EMAIL", "allowed_sender_addresses": ["noreply@yourdomain.com"] }
  ]
}
```

## Runtime API: `env.<BINDING>.send()`

Structured send — no `mimetext`/`EmailMessage` construction needed for
typical use (that's the older/legacy pattern; prefer this one for new code):

```js
const response = await env.EMAIL.send({
  to: "recipient@example.com",
  from: "sender@yourdomain.com",           // or { email, name } for a display name
  subject: "Subject line",
  html: "<h1>...</h1>",                     // optional
  text: "plain text fallback",              // optional
  cc: "cc@example.com",                     // optional, string | EmailAddress | array
  bcc: "bcc@example.com",                   // optional
  replyTo: "reply@example.com",             // optional
  attachments: [ /* Attachment[] */ ],      // optional
  headers: { "X-Custom": "value" },         // optional
});
// response.messageId
```

`to`/`from`/`cc`/`bcc` each accept `string | EmailAddress | (string|EmailAddress)[]`.
`EmailAddress` shape: `{ email: string, name?: string }` — use this to set a
friendly display name for the sender (e.g. `{ email: "backup@x.com", name: "Backup Bot" }`).

Combined `to` + `cc` + `bcc` addresses must not exceed 50.

`Attachment` shape: `{ content: string | ArrayBuffer | ArrayBufferView, filename: string, type: string, disposition: "attachment" | "inline", contentId?: string }`.

## The two domain requirements, and why they're different

1. **`from` domain** needs Cloudflare Email Routing enabled as a zone (DNS on
   Cloudflare, MX/SPF/DKIM records Cloudflare manages) — this is what lets
   Cloudflare authenticate mail sent *from* an address on that domain.

2. **Destination address** (`to`, or `destination_address` in the binding)
   verification is **account-level**, entirely separate from #1. Add it via
   the dashboard: Email → Email Routing → Destination Addresses → Add →
   Cloudflare emails a confirmation link to that address → click it. This
   works for literally any inbox — a personal Gmail, an address on a domain
   with unrelated email hosting, anything — because Cloudflare only needs to
   confirm you can read that inbox, not route mail to it. No MX or DNS change
   happens on the destination's domain.

A clean pattern that avoids ever touching a domain's real MX records: pick a
spare/unused domain purely as the `from` zone (enable Email Routing there,
nothing else lives on it), and set the destination address to wherever the
human actually reads mail (their real personal address), verified via the
account-level flow above.

## Common failure modes

| Error | Cause | Fix |
|---|---|---|
| `destination address is not a verified address` | The `to` address hasn't completed account-level verification | Add + verify it under Email Routing → Destination Addresses |
| Email silently doesn't arrive, no error | Often a spam-filtering issue or a `from` domain missing DKIM (Email Routing not actually enabled on that zone) | Confirm Email Routing status on the `from` domain in the dashboard |
| Deploy succeeds but binding shows wrong resource in `wrangler deploy` output | Stale `wrangler.toml` — the deploy output always echoes the actual bound resource; use it to sanity-check `destination_address` before troubleshooting further | Re-read the deploy output bindings table |

Sending to a verified destination address is free on every plan (Free and
Paid) and does not count toward any Email Sending quota.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall