agentleFS
aideploytutoraideploytutor/skill-deploy-share/skills/email-send/SKILL.md

email-send

Skill2 starsChanged 35 days agoMITView on GitHub

Let an app-foundation site send email from the owner's own domain (Resend, free tier 3,000/month), with DNS checks so mail doesn't land in spam and a /email-test page. Use when the user says "let my site send email", "send email from my domain", "set up Resend", or a later skill (auth-login, pay-receipts) requires email-send.

  • Reads credentials

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use a subdomain: Resend recommends it, and it keeps the root domain's own mailbox and reputation untouched.

    line 31
  2. Distinctive:

    Don't touch existing MX/TXT records for the root domain.

    line 69
  3. Distinctive:

    When it passes, click Verify in Resend (often verified within 15 minutes.

    line 84
  4. Very specific:

    Every send records email.sent or email.failed in core_events with a masked address (zh*@gmail.com), so other systems can react without …

    line 114

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

email-send

Goal: the site can email anyone (login codes, receipts, notifications) from the owner's own domain, and the mail reaches the inbox. Follow ../../STACK.md.

The owner may not be a programmer:

  • Signing up at Resend, accepting terms, and creating the API key are the owner's clicks.
  • The API key goes straight from Resend into Vercel. Never ask them to paste it into the chat, and never type it yourself.
  • Adding DNS records needs their OK, same as domain-setup.

Why Resend, and why your own domain

  • Free: 3,000 emails/month, max 100/day, 3 domains (checked 2026-10-14 at resend.com/pricing; check again before quoting). Paid starts at $20/month.
  • Without a verified domain, Resend only lets you send to your own address. So a real domain (episode 004) is required before strangers can get a login code.
  • The code calls Resend's plain HTTP API (no SDK), so it runs on Vercel and Cloudflare. Changing provider means rewriting only src/lib/email.ts.

Steps

1. Choose the sending address

Use a subdomain: Resend recommends it, and it keeps the root domain's own mailbox and reputation untouched.

SiteSending domainFrom
shop.example.com or example.commail.example.comMy Shop <hello@mail.example.com>

2. Prepare the code

node <skill-dir>/scripts/apply.mjs --dir "<project>" --sending-domain mail.example.com --json

Safe to run twice. Adds src/lib/email.ts (sendEmail()), the /email-test page, an .env.example block, stack.json → installed and email, and a git save point. Push it.

3. Resend account and domain (owner clicks; you guide)

  1. resend.com → sign up. "Log in with Google" is the simplest. The owner accepts the terms.
  2. Domains → Add domain → the sending domain from step 1. Pick the region nearest the users (default is fine).
  3. Resend shows the records. In October 2026 a new domain got these (older accounts may see MX + SPF TXT on send instead):
TypeHost (Namecheap/GoDaddy style, root domain left off)Value
TXTresend._domainkey.mailthe long DKIM key (p=MIGf...), nothing else
CNAMEsend.mailsend.forge.rmta.net
CNAMErsend.mailrsend.forge.rmta.net
TXT (recommended)_dmarc.mailv=DMARC1; p=none;

Copy the values from Resend's page, not from this table. Two changes from what Resend shows:

  • Resend lists DMARC with Host _dmarc, which sets a policy for the whole root domain. Use _dmarc.<sub> (e.g. _dmarc.mail), which covers only the sending subdomain.
  • Skip the Enable Receiving MX record unless the site must receive mail. That record is the one that could clash with an existing mailbox.

The page also offers "Go to <provider>". Some providers can add the records automatically. Treat that as the owner's choice and the owner's click.

4. Add the records at the DNS provider (owner's OK)

  • Namecheap / GoDaddy / Aliyun: the Host field already ends in the domain. Type only resend._domainkey.mail, not the full name, or it becomes ...labpencil.com.labpencil.com. The check script detects this mistake (doubled-host).
  • Copy one value at a time. In testing, the DKIM value got the next rows of the table pasted along with it. Resend stays Pending, and resolvers cache the wrong value for up to 30 min after it's fixed. The check script reports this as dkim-garbled. When you tell the owner what to paste, put each value in its own code block, not only in a table; copying from a table row is how it happened.
  • Cloudflare: grey cloud (DNS only) for everything. Proxied records break verification.
  • Don't touch existing MX/TXT records for the root domain. Those are their current mailbox.

Then check (read-only):

node <skill-dir>/scripts/check.mjs --domain mail.example.com --wait 900
CodeMeaning
dkim / spf / rsend / mxThat record isn't visible yet, or the value is wrong
dkim-garbledExtra text was pasted after the DKIM key; make the Value only p=...
doubled-hostThe full domain was typed into Host; keep only the part before it
dmarc (○, recommended)No DMARC yet. Add v=DMARC1; p=none; on _dmarc.<sending domain>

When it passes, click Verify in Resend (often verified within 15 minutes; DNS can take up to 72 h).

5. API key and variables (owner pastes the key)

  1. Resend → API Keys → Create API key, permission Sending access, domain = the sending domain.
  2. The owner copies it into Vercel → project → Settings → Environment Variables:
NameValueSecret?
RESEND_API_KEYre_...yes: owner only, mark Sensitive
EMAIL_FROMMy Shop <hello@mail.example.com>no
EMAIL_TEST_TOoptional: the owner's inbox, used when the recipient field is left empty (and the only address allowed without the code). Leave it out to keep the owner's address off the public pageno
EMAIL_TEST_CODEoptional test passphrase, needed to send to other addresses from /email-testyes: owner only

You may add the two non-secret ones yourself with the owner's OK.

  1. Redeploy so the variables take effect.

6. Test

Open https://<domain>/email-test, type any address (or leave it empty to use EMAIL_TEST_TO) → Send a test email. The page is public, so sending to an address other than EMAIL_TEST_TO requires EMAIL_TEST_CODE; without that variable it can only email the owner. It always allows at most one email a minute and 10 a day, with fixed content, so strangers can't use the domain to send spam. Never put the address in the URL. After auth-login (episode 006), consider limiting this page to admins. Ask the owner whether the email arrived in the inbox, not spam. In Gmail → ⋮ → Show original, SPF, DKIM and DMARC should all show PASS.

Using it in code

import { sendEmail } from "@/lib/email";
const r = await sendEmail({ to, subject: "Your sign-in code", text: `Your code is ${code}`, tag: "login-code" });
if (!r.ok) /* show a friendly error; r.error has details */;

Every send records email.sent or email.failed in core_events with a masked address (zh***@gmail.com), so other systems can react without exposing addresses.

Tell the user (short)

"Your site can now send email from hello@<sending domain>, free up to 3,000 emails a month and 100 a day." Add one line: next is auth-login (episode 006), which uses this to send login codes.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.