/lunora:lunora-setup-mailfrom Lunora
Adds transactional email to a Lunora app using the `@lunora/mail` registry item. Covers Resend, Cloudflare Email Workers, dev mail catcher, react-email templates, and E2E inbox helpers.
Ships in Lunora. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The mail registry item wraps @lunora/mail, which validates addresses against
header injection before sending. It exposes two internalActions, sendEmail
and queueEmail. Both are server-only on purpose: a mailer that lets the client
pick the recipient, subject and body is an open relay for phishing through your
verified domain. In dev, every send is captured into the Studio Mail tab and
nothing is delivered.
If the project has no Lunora backend yet, start with lunora-quickstart.
lunora add email # asks for the verified destination address
lunora add email --mail-to [email protected]
lunora registry add mail # low-level: leaves the [email protected] placeholder
Then run pnpm install and lunora codegen. The item does the following:
@lunora/mail and @lunora/server.lunora/mail/index.ts into the project. The project owns this file. It defines sendEmail, which returns { id }, and queueEmail, which returns { queued: true }.send_email binding named SEND_EMAIL (with destination_address) to wrangler.jsonc.MAIL_FROM to .dev.vars.Codegen emits the two functions as internal.mail.sendEmail and
internal.mail.queueEmail. They are not in the client-reachable api. A client
call to them returns FUNCTION_NOT_FOUND.
The copied file builds its mailer with createMailerFromEnv. That function
picks the transport in this order:
| Condition | Transport |
|---|---|
LUNORA_MAIL_CAPTURE=1, or a dev environment (below) | Capture into the Studio Mail tab |
SEND_EMAIL binding present | Cloudflare Email Workers |
no binding, RESEND_API_KEY secret set | Resend |
| none of the above | throws on send (production never captures silently) |
wrangler secret put RESEND_API_KEY and remove the send_email binding. While the binding exists it takes precedence over Resend.WORKER_ENV, NODE_ENV, …) looks like dev. lunora dev sets WORKER_ENV=development, so capture is on in dev. Capture writes to the root shard. If SHARD or LUNORA_ADMIN_TOKEN is missing, captured mail is discarded and a one-time warning is logged. To deliver for real from dev, set LUNORA_MAIL_CAPTURE=0.MAIL_FROM is required on every path. It accepts Name <addr@host> or a bare
address.
sendEmail is an action because sending is non-transactional network I/O. From
a mutation, schedule it so the send runs only after the mutation commits:
import { internal } from "#lunora/_generated/internal.js";
import { mutation, v } from "#lunora/_generated/server.js";
export const inviteMember = mutation.input({ teamId: v.id("teams"), email: v.string() }).mutation(async ({ ctx, args }) => {
// Authorize the caller and persist the invite first. The server decides
// the recipient and the content: never forward a client-chosen to/from/html.
await ctx.scheduler.runAfter(0, internal.mail.sendEmail, {
to: args.email,
subject: "You're invited",
html: "<p>Click the link to join.</p>",
});
});
Sending to an arbitrary args.email needs the Resend path in production: the
SEND_EMAIL binding only reaches its verified destination.
From an action, call await ctx.runAction(internal.mail.sendEmail, { … }).
If a client needs to trigger a send, write a public action for that one purpose.
It should take only business inputs (for example { orderId }), check
ctx.auth, derive the recipient on the server, rate-limit the call
(@lunora/ratelimit), and then call internal.mail.sendEmail.
A React element can't be serialized across the RPC boundary, so render it to
html and text first. Rendering this way keeps dev capture working:
import { renderEmail } from "@lunora/mail"; // needs `react` installed
import { WelcomeEmail } from "./emails/welcome";
const { html, text } = await renderEmail(<WelcomeEmail name={name} />);
await ctx.runAction(internal.mail.sendEmail, { to, subject: "Welcome", html, text });
For the auth flows, lunora add auth-emails adds ready-made templates.
queueEmail requires a Cloudflare Queue producer binding passed as
createMailerFromEnv(env, { queue }) in mailer(), and the item doesn't add one. Without it, the call
throws `queue` binding is required for mailer.queue(), except under
capture, where it sends straight to the capture inbox so dev flows keep working.
A consumer builds its mailer with createMailerFromEnv too, drains the queue
with consumeQueuedSend(mailer, message.body, { attempts: message.attempts, enqueuedAt: message.timestamp, sent: env.SENT }) and then calls
message.ack() for each message; sent (a KV namespace) lets a redelivered message whose key it
already recorded ack without a second send. That narrows duplicates rather than preventing them: KV
is eventually consistent, and a crash between the provider accepting the send and the record being
written resends it. enqueuedAt makes a send that may have landed non-retryable once the message is
23 hours old, since Resend drops a repeated key for only 24 hours, and a redelivery that old whose
earlier delivery may have landed (the store's per-delivery marks, or attempts without a store) is refused
before it reaches the provider. On a throw, branch on isRetryableMailError(error): retry with
message.retry() when it is true, and ack and log when it is false, since a refused
address or malformed body never sends and a retry only dead-letters it. A send
that timed out or hit Resend's 409 for a key still in flight (isOutcomeUnknownMailError(error))
may have been delivered: it is retryable only through Resend with an idempotency key (Resend drops
the repeat), and then retried with message.retry({ delaySeconds: 180 }) so the first attempt has
finished; otherwise it is acked and reported instead of resent. With a queue bound in dev, the message still goes through the
queue and the consumer's mailer captures it into the inbox. Queues deliver at least once: with
per-message acks a later throw retries only the unacknowledged messages, while
without them a single throw resends the whole batch. The full wiring is in the "Queueing"
section of the item README.
@lunora/mail/testing exports waitForMail({ baseUrl, adminToken, to, subjectMatch }) and extractLink(mail, { match }). Together they let you read the captured inbox and pull out a verification or reset link.@lunora/mail/inbound provides createInboundEmailHandler, parseInboundEmail and dispatchToLunoraFunction. They route Email Routing messages into a Lunora function. Mount them with the generated builder's .onEmail(...).lunora dev and trigger a send. With SHARD and LUNORA_ADMIN_TOKEN set, the message should appear in the Studio Mail tab; if either is missing, capture discards it and logs a warning.lunora doctor. It flags the placeholder destination. Confirm that MAIL_FROM is set, and that either the binding uses a verified destination or RESEND_API_KEY is set with the binding removed.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub anolilab/lunora --plugin lunora15 skills in this plugin
/lunoraRoutes general Lunora requests to the right Lunora skill and gives the shared mental model (codegen loop, generated `api`/`internal` references, review commands, add-on capabilities, the `@lunora/mcp` server). Use when the user asks which Lunora skill to use, gives an underspecified task in a project with a `lunora/` directory or `lunorash`/`@lunora/*` dependencies, asks to review or audit Lunora code, asks about an add-on without its own skill (queues, workflows, agents, AI, flags, payments, notifications), or wants to expose a deployment to an AI agent over MCP./lunora-cloudflare-auditAudits a Lunora app for Cloudflare cost and reliability risk before launch or after a surprise bill. Chains the read-only `lunora doctor`, `lunora advisor` and `lunora insights` signals, then traces what they cannot see — retry and fan-out loops, cron cadence, public routes that reach a metered product (Workers AI, Browser, Containers, Vectorize, R2, D1), preview environments with paid bindings, and missing usage alerts (`lunora cloudflare alerts`). Reports each finding with the billing meter it moves, the smallest fix, and how to verify. Use when the user asks to "audit before launch", "what could blow up our Cloudflare bill", "why did the bill spike", "is this safe to put on the public internet", or "review our cron / queue / AI / workflow cost". For a slow query or OCC conflict use `lunora-performance-audit`; for a failing deploy use `lunora-deploy`./lunora-create-packageBuilds a reusable Lunora capability, either as a registry item that `lunora add` / `lunora registry add` copies into an app's `lunora/`, or as a publishable `@lunora/*` workspace package in the Lunora monorepo. Use when the user wants to package schema + functions + wrangler bindings + env vars for other apps, add or edit an item under `registry/<name>/` (`registry.json`), run `vis generate lunora-package`, or wire a new `ctx.*` capability into codegen./lunora-deployDeploys a Lunora app to Cloudflare Workers + Durable Objects and gets wrangler.jsonc, remote resources and secrets to line up. Covers `lunora deploy` (and `--env`, `--dry-run`, `--migrate`), isolated per-PR previews (`lunora preview deploy | list | delete`), the `lunora doctor` / `lunora verify` / `lunora prepare` preflights, Durable Object bindings (SHARD, SHARD_REGISTRY, SCHEDULER), the `DB` D1 binding and its placeholder id, R2 buckets, production secrets (`lunora env push`, `wrangler secret put`) versus `.dev.vars`, the schema-drift gate, the architecture diff, and rollback with `lunora cloudflare deployments`. Use when the user asks to "deploy", "ship to production", "set up a staging environment", wire CI deploys, or when a deploy fails on a binding, a placeholder `database_id`, an unexported Durable Object class, a missing secret, or "schema drift gate blocked deploy"./lunora-functionsAuthoring rules for Lunora schema and server functions under `lunora/` — `defineSchema`/`defineTable`, `v.*` validators, the generated `query`/`mutation`/`action` builders (and `internal*`), indexes and `withIndex`, the `ctx.db` API, pagination, `ctx.db.related`, opt-in `ctx.*` capabilities, topics, modules, services, and `httpAction`. Use when writing or reviewing files in `lunora/` (`schema.ts`, function files, `http.ts`, `queues.ts`), when asked to "add a query/mutation/action", "add an index", "call one function from another", or "add a webhook endpoint", or when `lunora codegen` reports an error in a function./lunora-migration-helperPlans and runs Lunora schema and data migrations with the widen → migrate → narrow pattern. Covers online data migrations (`defineMigration` in `lunora/migrations.ts`, `lunora migrate create | up | down | status`), what the pre-deploy schema-drift gate treats as breaking and how a migration covers it, `.global()` table DDL on D1 (`lunora migrate generate`) and Hyperdrive, moving a dataset with `lunora migrate d1-to-hyperdrive` (and back with `hyperdrive-to-d1`), and re-keying a `.shardBy()` table. Use when the user wants to make a field required, rename or drop a field or table, change a field's type, add a unique index to a populated table, backfill data, switch a table between root / `.shardBy()` / `.global()`, or when `lunora deploy` reports "schema drift gate blocked".Other plugins' skills for the same job