[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F93AYPVZEACFM9B00AFA5T":3,"skill-same:01M7F93AYPVZEACFM9B00AFA5T":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":39,"commitSha":40,"skillDirectory":41,"forksCount":42,"repositoryHtmlUrl":43,"repositoryHomepageUrl":6,"ownerHtmlUrl":44,"ownerBlogUrl":6,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M7F93AYPVZEACFM9B00AFA5T","email-connector",null,"Use when wiring server code to send transactional or bulk email via Resend, SendGrid, or Postmark: a provider-agnostic sendEmail() seam, idempotent retries, 100-cap batches with partial failures, transactional-vs-broadcast streams, bounce webhooks feeding a suppression list. NOT SPF\u002FDKIM\u002FDMARC inbox reputation (that is `email-deliverability`).","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Femail-connector\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: email-connector\ndescription: \"Use when wiring server code to send transactional or bulk email via Resend, SendGrid, or Postmark: a provider-agnostic sendEmail() seam, idempotent retries, 100-cap batches with partial failures, transactional-vs-broadcast streams, bounce webhooks feeding a suppression list. NOT SPF\u002FDKIM\u002FDMARC inbox reputation (that is `email-deliverability`).\"\ntags: [email, transactional-email, resend, sendgrid, postmark, webhooks, idempotency]\nrecommends: [email-deliverability, newsletter, webhooks, secure-coding, api-connector-builder, automation-flows]\norigin: risco\n---\n\n# email-connector — put transactional & bulk email on the wire\n\nYou wire the *send*. A welcome mail, a password reset, a receipt, a 4,000-row\ndigest — your job is the server code that hands it to a provider, makes it safe\nto retry, and keeps the suppression list honest. You do **not** own the inbox\n(SPF\u002FDKIM\u002FDMARC\u002Freputation is `..\u002Femail-deliverability\u002FSKILL.md`) and you do\n**not** own the words (subject lines and growth are `..\u002Fnewsletter\u002FSKILL.md`,\nlaunch copy is `..\u002Fmarketing\u002FSKILL.md`). Generic typed clients for *any* REST API\nare `..\u002Fapi-connector-builder\u002FSKILL.md`; deciding *when* a multi-step sequence\nfires is `..\u002Fautomation-flows\u002FSKILL.md`.\n\nStack as of June 2026: `resend` 6.12.4, `@sendgrid\u002Fmail` 8.1.6, Postmark via its\nHTTP API, React Email 5.0 (React 19.2 \u002F Next.js 16, Tailwind 4), Node 20+ \u002F TS.\n\n`scripts\u002Fverify.sh` is read-only and greps a target for the four invariants this\nskill exists to hold: env-sourced key, idempotency, a single `sendEmail()` seam,\nand a webhook signature checked on the raw body.\n\n## Step 1 — pick a provider\n\n| Provider | Best default fit | Native idempotency | Template model | Batch cap | Pick when |\n|----------|------------------|--------------------|----------------|-----------|-----------|\n| **Resend** | Greenfield, React\u002FNext shops | Yes — `{ idempotencyKey }`, 24h, ≤256 chars | React Email JSX via `react:` | 100\u002Fcall | You want JSX templates and the least ceremony |\n| **SendGrid (Twilio)** | High volume, marketing+txn mix | No — dedupe yourself | `d-` dynamic templates + `dynamicTemplateData` | per-send `personalizations` | You need 10k req\u002Fs scale or already on Twilio |\n| **Postmark** | Pure transactional, deliverability-first | No — self-dedupe via your key + webhooks | Postmark server templates | per-stream | Receipts\u002Fresets must never queue behind marketing |\n\nIdempotency support changes your strategy, not just your config — see Step 4.\nFull per-provider matrix (auth header, SDK + version, single\u002Fbatch signatures,\nidempotency model, stream\u002Fsubdomain model, dynamic-template syntax, webhook event\nnames, rate limits, when to pick each) plus a suppression-webhook handler skeleton\nper provider is in `references\u002Fproviders.md`.\n\n## Step 2 — the `sendEmail()` seam\n\nOne provider-agnostic function. The rest of the app calls `sendEmail(...)` and\nnever imports a provider SDK. *Why:* swapping SendGrid→Postmark is then one file,\nnot a grep across every call site. That one file reads the key from\n`process.env` — never a `re_…` \u002F `SG.…` \u002F server-token literal, because a\ncommitted key is a send-as-you credential and burns your reputation with it.\n\n```ts\n\u002F\u002F lib\u002Femail\u002Findex.ts — the only place a provider SDK is imported\nexport type SendArgs = {\n  to: string | string[];\n  subject: string;\n  react?: React.ReactElement; \u002F\u002F template component\n  html?: string;\n  text?: string;\n  idempotencyKey: string;     \u002F\u002F required for transactional sends\n  stream?: 'transactional' | 'broadcast';\n};\nexport async function sendEmail(args: SendArgs): Promise\u003C{ id: string }> { \u002F* provider impl *\u002F }\n```\n\n```ts\n\u002F\u002F lib\u002Femail\u002Fresend.ts\nimport { Resend } from 'resend';\nconst resend = new Resend(process.env.RESEND_API_KEY);\n\nexport async function sendEmail(a: SendArgs) {\n  const { data, error } = await resend.emails.send(\n    { from: 'YourApp \u003Cnoreply@notify.yourdomain.com>', to: a.to, subject: a.subject, react: a.react, html: a.html, text: a.text },\n    { idempotencyKey: a.idempotencyKey }, \u002F\u002F 2nd arg, retained 24h, ≤256 chars\n  );\n  if (error) throw new Error(error.message);\n  return { id: data!.id };\n}\n```\n\n```ts\n\u002F\u002F lib\u002Femail\u002Fsendgrid.ts\nimport sgMail from '@sendgrid\u002Fmail';\nsgMail.setApiKey(process.env.SENDGRID_API_KEY!);\n\nexport async function sendEmail(a: SendArgs) {\n  const [res] = await sgMail.send({\n    from: 'noreply@notify.yourdomain.com',\n    to: a.to, subject: a.subject, html: a.html, text: a.text,\n    \u002F\u002F SendGrid has no idempotency key — guard with your own dedupe (Step 4)\n  });\n  return { id: res.headers['x-message-id'] };\n}\n```\n\n```ts\n\u002F\u002F lib\u002Femail\u002Fpostmark.ts — raw HTTP, X-Postmark-Server-Token header\nexport async function sendEmail(a: SendArgs) {\n  \u002F\u002F Postmark has no idempotency key: self-dedupe BEFORE calling (Step 4)\n  const r = await fetch('https:\u002F\u002Fapi.postmarkapp.com\u002Femail', {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application\u002Fjson',\n      Accept: 'application\u002Fjson',\n      'X-Postmark-Server-Token': process.env.POSTMARK_SERVER_TOKEN!,\n    },\n    body: JSON.stringify({\n      From: 'noreply@notify.yourdomain.com',\n      To: Array.isArray(a.to) ? a.to.join(',') : a.to,\n      Subject: a.subject, HtmlBody: a.html, TextBody: a.text,\n      MessageStream: a.stream === 'broadcast' ? 'broadcast' : 'outbound',\n    }),\n  });\n  if (!r.ok) throw new Error(`Postmark ${r.status}`);\n  return { id: (await r.json()).MessageID };\n}\n```\n\nBad → Good:\n\n```ts\n\u002F\u002F Bad — provider SDK called directly in a route handler, key inline\nimport { Resend } from 'resend';\nawait new Resend('re_live_123abc').emails.send({ to, subject, html });\n```\n```ts\n\u002F\u002F Good — call the seam; key is in env, swap is one file\nimport { sendEmail } from '@\u002Flib\u002Femail';\nawait sendEmail({ to, subject, react: \u003CWelcome name={n} \u002F>, idempotencyKey });\n```\n\n## Step 3 — templates\n\nTemplates are typed components, not string concat. *Why:* JSX escapes\ninterpolated values; hand-built HTML invites injection and broken markup.\n\nReact Email 5.0 renamed `renderAsync` → `render`. The Resend SDK lazily imports\n`@react-email\u002Frender` when you pass `react:`, so you usually pass the component\ndirectly and skip manual rendering.\n\n```tsx\n\u002F\u002F emails\u002Fwelcome.tsx\nimport { Html, Button, Text } from '@react-email\u002Fcomponents';\nexport function Welcome({ name, url }: { name: string; url: string }) {\n  return (\n    \u003CHtml>\n      \u003CText>Welcome, {name}.\u003C\u002FText>\n      \u003CButton href={url}>Confirm your email\u003C\u002FButton>\n    \u003C\u002FHtml>\n  );\n}\n```\n\n```ts\n\u002F\u002F SendGrid: dynamic template referenced by a d- id, data passed separately\nawait sgMail.send({\n  to, from: 'noreply@notify.yourdomain.com',\n  templateId: 'd-abc123...',                  \u002F\u002F dynamic template id starts with d-\n  dynamicTemplateData: { name, confirm_url },  \u002F\u002F values, not pre-rendered HTML\n});\n```\n\n```ts\n\u002F\u002F Bad — string concat, unescaped user input straight into HTML\nconst html = '\u003Ch1>Hi ' + req.body.name + '\u003C\u002Fh1>'; \u002F\u002F XSS + broken layout risk\n```\n\n## Step 4 — idempotency & retries\n\nEvery transactional send carries a key, because queues retry, serverless\nfunctions re-fire, and users double-click — without a stable key one password\nreset becomes three. Derive it from the *event*, not the clock. Same event → same\nkey → provider (or your table) collapses the duplicate.\n\n```ts\nconst idempotencyKey = `pwreset:${userId}:${tokenVersion}`; \u002F\u002F stable across retries\n```\n\n- **Resend:** native. Pass `{ idempotencyKey }` as the 2nd arg; retained 24h,\n  ≤256 chars. For a batch, the key represents the whole batch (e.g.\n  `team-quota\u002F123456789`), not each row.\n- **Postmark \u002F SendGrid:** no idempotency feature. You must self-dedupe: write\n  the key to a `sent_emails` table inside the same transaction as the send,\n  unique-constrain it, and skip if it already exists.\n\n```ts\n\u002F\u002F Self-dedupe seam for providers without native keys\nconst inserted = await db.sentEmails.insertIfAbsent({ key: idempotencyKey });\nif (!inserted) return; \u002F\u002F already sent — do not re-fire\nawait sendEmail({ to, subject, html, idempotencyKey });\n```\n\n```ts\n\u002F\u002F Bad — no key; queue retry sends the reset 3×\nawait sendEmail({ to, subject, react: \u003CReset url={url} \u002F> } as any);\n```\n\n## Step 5 — batch \u002F bulk\n\n`resend.batch.send([...])` is capped at **100 emails per call** and forbids\nattachments\u002Fscheduling. Chunk larger runs, then inspect *both* arrays for\npartial failure — a 200 response can still contain per-row errors.\n\nChecklist for a bulk run:\n\n- [ ] Filter the recipient list against the suppression list (Step 7) first.\n- [ ] Chunk into ≤100; one `idempotencyKey` per chunk.\n- [ ] Use `batchValidation: 'permissive'` so one bad address does not nuke the chunk.\n- [ ] Iterate results: collect succeeded ids and failed rows separately.\n- [ ] Re-queue only the failed rows; never replay the whole chunk.\n\n```ts\nfunction chunk\u003CT>(xs: T[], n = 100) { const o: T[][] = []; for (let i = 0; i \u003C xs.length; i += n) o.push(xs.slice(i, i + n)); return o; }\n\nfor (const [i, group] of chunk(recipients).entries()) {\n  const { data } = await resend.batch.send(\n    group.map((r) => ({ from, to: r.email, subject, react: \u003CDigest items={r.items} \u002F> })),\n    { idempotencyKey: `digest-2026-06\u002F${i}`, batchValidation: 'permissive' },\n  );\n  data?.data?.forEach((d) => markSent(d.id));      \u002F\u002F succeeded rows\n  \u002F\u002F inspect per-row errors and re-queue only those — do not replay the chunk\n}\n```\n\n## Step 6 — transactional vs broadcast split\n\nReputation isolation. Give each stream a distinct From, subdomain, and\nstream\u002FIP so they cannot poison each other:\n\n| Stream | From | Subdomain | Provider stream |\n|--------|------|-----------|-----------------|\n| Transactional | `noreply@notify.yourdomain.com` | `notify.` | Resend default \u002F Postmark `outbound` |\n| Broadcast | `news@promo.yourdomain.com` | `promo.` | dedicated marketing stream \u002F `broadcast` |\n\n*Why:* a marketing send that trips a blocklist must never take password resets\ndown with it. The DNS\u002Fauth setup for those subdomains is\n`..\u002Femail-deliverability\u002FSKILL.md`'s job; you just send on the right one.\n\n## Step 7 — delivery\u002Fbounce\u002Fcomplaint webhook → suppression\n\nThe provider POSTs bounce and complaint events. Verify the signature on the\n**raw** body (parse after verifying), then write the address to a suppression\nlist and check that list before every future send. The verification is absolute\nbecause this hook mutates the suppression list: unverified, anyone can suppress\n— or un-suppress — your users.\n\n```ts\n\u002F\u002F app\u002Fapi\u002Femail\u002Fwebhook\u002Froute.ts (Next.js 16) — verify BEFORE parsing\nexport async function POST(req: Request) {\n  const raw = await req.text();                       \u002F\u002F raw body, not req.json()\n  if (!verifyProviderSignature(raw, req.headers)) return new Response('bad sig', { status: 401 });\n  const event = JSON.parse(raw);\n  if (event.type === 'email.bounced' || event.type === 'email.complained') {\n    await db.suppressions.upsert({ email: event.data.to, reason: event.type });\n  }\n  return new Response('ok');\n}\n```\n\n```ts\n\u002F\u002F Before any send: skip suppressed addresses\nconst recipients = candidates.filter(async (e) => !(await db.suppressions.has(e)));\n```\n\nGeneric webhook hardening (replay windows, queueing, retries beyond email) is\n`..\u002Fwebhooks\u002FSKILL.md`. The address-validity question (is this mailbox real\nbefore I ever send) is `..\u002Flead-gen\u002FSKILL.md` \u002F `..\u002Femail-deliverability\u002FSKILL.md`.\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n|--------------|--------------|------------|\n| API key hard-coded (`re_…`, `SG.…`, server token) | Committed credential = send-as-you abuse | Read from `process.env`; rotate via `..\u002Fsecure-coding\u002FSKILL.md` |\n| No idempotency key on transactional sends | Queue\u002Fserverless retry double-sends | Deterministic `event:userId:version` key |\n| One stream for everything | Marketing hit poisons reset\u002Freceipt deliverability | Split From + subdomain + stream (Step 6) |\n| String-concatenated HTML with user input | XSS + broken layout | React Email component or `d-` dynamic template |\n| Ignoring per-row `data.errors` in a batch | Silent partial loss; \"looked like 200\" | Inspect both arrays; re-queue only failures |\n| Trusting the webhook without signature check | Anyone can poison your suppression list | Verify signature on raw body, then parse |\n| Sending to a bounced\u002Fcomplained address | Reputation damage, ISP penalties | Filter against suppression list before send |\n| Calling the provider SDK at scattered call sites | Provider swap = grep across the app | One `sendEmail()` seam (Step 2) |\n","# email-connector — put transactional & bulk email on the wire\n\nYou wire the *send*. A welcome mail, a password reset, a receipt, a 4,000-row\ndigest — your job is the server code that hands it to a provider, makes it safe\nto retry, and keeps the suppression list honest. You do **not** own the inbox\n(SPF\u002FDKIM\u002FDMARC\u002Freputation is `..\u002Femail-deliverability\u002FSKILL.md`) and you do\n**not** own the words (subject lines and growth are `..\u002Fnewsletter\u002FSKILL.md`,\nlaunch copy is `..\u002Fmarketing\u002FSKILL.md`). Generic typed clients for *any* REST API\nare `..\u002Fapi-connector-builder\u002FSKILL.md`; deciding *when* a multi-step sequence\nfires is `..\u002Fautomation-flows\u002FSKILL.md`.\n\nStack as of June 2026: `resend` 6.12.4, `@sendgrid\u002Fmail` 8.1.6, Postmark via its\nHTTP API, React Email 5.0 (React 19.2 \u002F Next.js 16, Tailwind 4), Node 20+ \u002F TS.\n\n`scripts\u002Fverify.sh` is read-only and greps a target for the four invariants this\nskill exists to hold: env-sourced key, idempotency, a single `sendEmail()` seam,\nand a webhook signature checked on the raw body.\n\n## Step 1 — pick a provider\n\n| Provider | Best default fit | Native idempotency | Template model | Batch cap | Pick when |\n|----------|------------------|--------------------|----------------|-----------|-----------|\n| **Resend** | Greenfield, React\u002FNext shops | Yes — `{ idempotencyKey }`, 24h, ≤256 chars | React Email JSX via `react:` | 100\u002Fcall | You want JSX templates and the least ceremony |\n| **SendGrid (Twilio)** | High volume, marketing+txn mix | No — dedupe yourself | `d-` dynamic templates + `dynamicTemplateData` | per-send `personalizations` | You need 10k req\u002Fs scale or already on Twilio |\n| **Postmark** | Pure transactional, deliverability-first | No — self-dedupe via your key + webhooks | Postmark server templates | per-stream | Receipts\u002Fresets must never queue behind marketing |\n\nIdempotency support changes your strategy, not just your config — see Step 4.\nFull per-provider matrix (auth header, SDK + version, single\u002Fbatch signatures,\nidempotency model, stream\u002Fsubdomain model, dynamic-template syntax, webhook event\nnames, rate limits, when to pick each) plus a suppression-webhook handler skeleton\nper provider is in `references\u002Fproviders.md`.\n\n## Step 2 — the `sendEmail()` seam\n\nOne provider-agnostic function. The rest of the app calls `sendEmail(...)` and\nnever imports a provider SDK. *Why:* swapping SendGrid→Postmark is then one file,\nnot a grep across every call site. That one file reads the key from\n`process.env` — never a `re_…` \u002F `SG.…` \u002F server-token literal, because a\ncommitted key is a send-as-you credential and burns your reputation with it.\n\n```ts\n\u002F\u002F lib\u002Femail\u002Findex.ts — the only place a provider SDK is imported\nexport type SendArgs = {\n  to: string | string[];\n  subject: string;\n  react?: React.ReactElement; \u002F\u002F template component\n  html?: string;\n  text?: string;\n  idempotencyKey: string;     \u002F\u002F required for transactional sends\n  stream?: 'transactional' | 'broadcast';\n};\nexport async function sendEmail(args: SendArgs): Promise\u003C{ id: string }> { \u002F* provider impl *\u002F }\n```\n\n```ts\n\u002F\u002F lib\u002Femail\u002Fresend.ts\nimport { Resend } from 'resend';\nconst resend = new Resend(process.env.RESEND_API_KEY);\n\nexport async function sendEmail(a: SendArgs) {\n  const { data, error } = await resend.emails.send(\n    { from: 'YourApp \u003Cnoreply@notify.yourdomain.com>', to: a.to, subject: a.subject, react: a.react, html: a.html, text: a.text },\n    { idempotencyKey: a.idempotencyKey }, \u002F\u002F 2nd arg, retained 24h, ≤256 chars\n  );\n  if (error) throw new Error(error.message);\n  return { id: data!.id };\n}\n```\n\n```ts\n\u002F\u002F lib\u002Femail\u002Fsendgrid.ts\nimport sgMail from '@sendgrid\u002Fmail';\nsgMail.setApiKey(process.env.SENDGRID_API_KEY!);\n\nexport async function sendEmail(a: SendArgs) {\n  const [res] = await sgMail.send({\n    from: 'noreply@notify.yourdomain.com',\n    to: a.to, subject: a.subject, html: a.html, text: a.text,\n    \u002F\u002F SendGrid has no idempotency key — guard with your own dedupe (Step 4)\n  });\n  return { id: res.headers['x-message-id'] };\n}\n```\n\n```ts\n\u002F\u002F lib\u002Femail\u002Fpostmark.ts — raw HTTP, X-Postmark-Server-Token header\nexport async function sendEmail(a: SendArgs) {\n  \u002F\u002F Postmark has no idempotency key: self-dedupe BEFORE calling (Step 4)\n  const r = await fetch('https:\u002F\u002Fapi.postmarkapp.com\u002Femail', {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application\u002Fjson',\n      Accept: 'application\u002Fjson',\n      'X-Postmark-Server-Token': process.env.POSTMARK_SERVER_TOKEN!,\n    },\n    body: JSON.stringify({\n      From: 'noreply@notify.yourdomain.com',\n      To: Array.isArray(a.to) ? a.to.join(',') : a.to,\n      Subject: a.subject, HtmlBody: a.html, TextBody: a.text,\n      MessageStream: a.stream === 'broadcast' ? 'broadcast' : 'outbound',\n    }),\n  });\n  if (!r.ok) throw new Error(`Postmark ${r.status}`);\n  return { id: (await r.json()).MessageID };\n}\n```\n\nBad → Good:\n\n```ts\n\u002F\u002F Bad — provider SDK called directly in a route handler, key inline\nimport { Resend } from 'resend';\nawait new Resend('re_live_123abc').emails.send({ to, subject, html });\n```\n```ts\n\u002F\u002F Good — call the seam; key is in env, swap is one file\nimport { sendEmail } from '@\u002Flib\u002Femail';\nawait sendEmail({ to, subject, react: \u003CWelcome name={n} \u002F>, idempotencyKey });\n```\n\n## Step 3 — templates\n\nTemplates are typed components, not string concat. *Why:* JSX escapes\ninterpolated values; hand-built HTML invites injection and broken markup.\n\nReact Email 5.0 renamed `renderAsync` → `render`. The Resend SDK lazily imports\n`@react-email\u002Frender` when you pass `react:`, so you usually pass the component\ndirectly and skip manual rendering.\n\n```tsx\n\u002F\u002F emails\u002Fwelcome.tsx\nimport { Html, Button, Text } from '@react-email\u002Fcomponents';\nexport function Welcome({ name, url }: { name: string; url: string }) {\n  return (\n    \u003CHtml>\n      \u003CText>Welcome, {name}.\u003C\u002FText>\n      \u003CButton href={url}>Confirm your email\u003C\u002FButton>\n    \u003C\u002FHtml>\n  );\n}\n```\n\n```ts\n\u002F\u002F SendGrid: dynamic template referenced by a d- id, data passed separately\nawait sgMail.send({\n  to, from: 'noreply@notify.yourdomain.com',\n  templateId: 'd-abc123...',                  \u002F\u002F dynamic template id starts with d-\n  dynamicTemplateData: { name, confirm_url },  \u002F\u002F values, not pre-rendered HTML\n});\n```\n\n```ts\n\u002F\u002F Bad — string concat, unescaped user input straight into HTML\nconst html = '\u003Ch1>Hi ' + req.body.name + '\u003C\u002Fh1>'; \u002F\u002F XSS + broken layout risk\n```\n\n## Step 4 — idempotency & retries\n\nEvery transactional send carries a key, because queues retry, serverless\nfunctions re-fire, and users double-click — without a stable key one password\nreset becomes three. Derive it from the *event*, not the clock. Same event → same\nkey → provider (or your table) collapses the duplicate.\n\n```ts\nconst idempotencyKey = `pwreset:${userId}:${tokenVersion}`; \u002F\u002F stable across retries\n```\n\n- **Resend:** native. Pass `{ idempotencyKey }` as the 2nd arg; retained 24h,\n  ≤256 chars. For a batch, the key represents the whole batch (e.g.\n  `team-quota\u002F123456789`), not each row.\n- **Postmark \u002F SendGrid:** no idempotency feature. You must self-dedupe: write\n  the key to a `sent_emails` table inside the same transaction as the send,\n  unique-constrain it, and skip if it already exists.\n\n```ts\n\u002F\u002F Self-dedupe seam for providers without native keys\nconst inserted = await db.sentEmails.insertIfAbsent({ key: idempotencyKey });\nif (!inserted) return; \u002F\u002F already sent — do not re-fire\nawait sendEmail({ to, subject, html, idempotencyKey });\n```\n\n```ts\n\u002F\u002F Bad — no key; queue retry sends the reset 3×\nawait sendEmail({ to, subject, react: \u003CReset url={url} \u002F> } as any);\n```\n\n## Step 5 — batch \u002F bulk\n\n`resend.batch.send([...])` is capped at **100 emails per call** and forbids\nattachments\u002Fscheduling. Chunk larger runs, then inspect *both* arrays for\npartial failure — a 200 response can still contain per-row errors.\n\nChecklist for a bulk run:\n\n- [ ] Filter the recipient list against the suppression list (Step 7) first.\n- [ ] Chunk into ≤100; one `idempotencyKey` per chunk.\n- [ ] Use `batchValidation: 'permissive'` so one bad address does not nuke the chunk.\n- [ ] Iterate results: collect succeeded ids and failed rows separately.\n- [ ] Re-queue only the failed rows; never replay the whole chunk.\n\n```ts\nfunction chunk\u003CT>(xs: T[], n = 100) { const o: T[][] = []; for (let i = 0; i \u003C xs.length; i += n) o.push(xs.slice(i, i + n)); return o; }\n\nfor (const [i, group] of chunk(recipients).entries()) {\n  const { data } = await resend.batch.send(\n    group.map((r) => ({ from, to: r.email, subject, react: \u003CDigest items={r.items} \u002F> })),\n    { idempotencyKey: `digest-2026-06\u002F${i}`, batchValidation: 'permissive' },\n  );\n  data?.data?.forEach((d) => markSent(d.id));      \u002F\u002F succeeded rows\n  \u002F\u002F inspect per-row errors and re-queue only those — do not replay the chunk\n}\n```\n\n## Step 6 — transactional vs broadcast split\n\nReputation isolation. Give each stream a distinct From, subdomain, and\nstream\u002FIP so they cannot poison each other:\n\n| Stream | From | Subdomain | Provider stream |\n|--------|------|-----------|-----------------|\n| Transactional | `noreply@notify.yourdomain.com` | `notify.` | Resend default \u002F Postmark `outbound` |\n| Broadcast | `news@promo.yourdomain.com` | `promo.` | dedicated marketing stream \u002F `broadcast` |\n\n*Why:* a marketing send that trips a blocklist must never take password resets\ndown with it. The DNS\u002Fauth setup for those subdomains is\n`..\u002Femail-deliverability\u002FSKILL.md`'s job; you just send on the right one.\n\n## Step 7 — delivery\u002Fbounce\u002Fcomplaint webhook → suppression\n\nThe provider POSTs bounce and complaint events. Verify the signature on the\n**raw** body (parse after verifying), then write the address to a suppression\nlist and check that list before every future send. The verification is absolute\nbecause this hook mutates the suppression list: unverified, anyone can suppress\n— or un-suppress — your users.\n\n```ts\n\u002F\u002F app\u002Fapi\u002Femail\u002Fwebhook\u002Froute.ts (Next.js 16) — verify BEFORE parsing\nexport async function POST(req: Request) {\n  const raw = await req.text();                       \u002F\u002F raw body, not req.json()\n  if (!verifyProviderSignature(raw, req.headers)) return new Response('bad sig', { status: 401 });\n  const event = JSON.parse(raw);\n  if (event.type === 'email.bounced' || event.type === 'email.complained') {\n    await db.suppressions.upsert({ email: event.data.to, reason: event.type });\n  }\n  return new Response('ok');\n}\n```\n\n```ts\n\u002F\u002F Before any send: skip suppressed addresses\nconst recipients = candidates.filter(async (e) => !(await db.suppressions.has(e)));\n```\n\nGeneric webhook hardening (replay windows, queueing, retries beyond email) is\n`..\u002Fwebhooks\u002FSKILL.md`. The address-validity question (is this mailbox real\nbefore I ever send) is `..\u002Flead-gen\u002FSKILL.md` \u002F `..\u002Femail-deliverability\u002FSKILL.md`.\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n|--------------|--------------|------------|\n| API key hard-coded (`re_…`, `SG.…`, server token) | Committed credential = send-as-you abuse | Read from `process.env`; rotate via `..\u002Fsecure-coding\u002FSKILL.md` |\n| No idempotency key on transactional sends | Queue\u002Fserverless retry double-sends | Deterministic `event:userId:version` key |\n| One stream for everything | Marketing hit poisons reset\u002Freceipt deliverability | Split From + subdomain + stream (Step 6) |\n| String-concatenated HTML with user input | XSS + broken layout | React Email component or `d-` dynamic template |\n| Ignoring per-row `data.errors` in a batch | Silent partial loss; \"looked like 200\" | Inspect both arrays; re-queue only failures |\n| Trusting the webhook without signature check | Anyone can poison your suppression list | Verify signature on raw body, then parse |\n| Sending to a bounced\u002Fcomplained address | Reputation damage, ISP penalties | Filter against suppression list before send |\n| Calling the provider SDK at scattered call sites | Provider swap = grep across the app | One `sendEmail()` seam (Step 2) |\n",{"name":5,"tags":24,"origin":32,"recommends":33,"description":7},[25,26,27,28,29,30,31],"email","transactional-email","resend","sendgrid","postmark","webhooks","idempotency","risco",[34,35,30,36,37,38],"email-deliverability","newsletter","secure-coding","api-connector-builder","automation-flows","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","06-前端与设计\u002Femail-connector",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill email-connector",{"tool":53,"command":54},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill email-connector",{"tool":56,"command":57},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill email-connector","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Femail-connector\u002FSKILL.md",true,[61,67,71],{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"evals\u002Fcases.yaml","REFERENCE","参考文档",3547,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Femail-connector\u002Fevals\u002Fcases.yaml",{"path":68,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":69,"sourceHtmlUrl":70},"evals\u002FREADME.md",1181,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Femail-connector\u002Fevals\u002FREADME.md",{"path":72,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fproviders.md",4819,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F06-前端与设计\u002Femail-connector\u002Freferences\u002Fproviders.md",[76,83,88,95,102,109],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],{"skillNo":84,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":19},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":19},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]