型付き React Email テンプレートによるトランザクションメール:Resend、SMTP、開発時はコンソール
コード9 ファイルコンテキスト約 544 トークンスキャン合格
インストール
$
genpm add @core/email含まれるもの
- src/lib/email/ にソースコード(9 ファイル)。 (11.8 KB)
- src/lib/email/AGENTS.md に AI ルール、加えて IDE 用のルールファイル。
- .env.example に追加される環境変数: RESEND_API_KEY, EMAIL_FROM。
README
このパッケージには README がありません。
約 544 トークン→ src/lib/email/AGENTS.md→ .cursor/rules/genpm-core-email.mdc
これは AI が src/lib/email で作業するときに読む内容そのものです。それ以外はコンテキストに追加されません。
@core/email — rules for AI agents
Purpose
Transactional email with typed templates: sendEmail('welcome', { to, props }). Providers: Resend (default), SMTP
(optional, via nodemailer) and a console provider for development. Templates use React Email. No marketing lists,
no queues, no tracking pixels.
Map
index.ts— public API:sendEmail,renderEmail,setEmailProvider, provider factories,TemplateProps.send.ts— the template registry (templates) andsendEmail.templates/*.ts—welcome,magicLink,receipt, plus the sharedlayout.ts.providers.ts—EmailProviderinterface and implementations.
Integration
- Env:
EMAIL_FROM("App <hello@yourdomain.com>") andRESEND_API_KEY(verify the domain in Resend first). WithoutRESEND_API_KEY, outside production, emails are printed to the console.@types/reactis only needed at build time: move it to devDependencies if GenPM added it to dependencies. SMTP instead:EMAIL_PROVIDER=smtp,SMTP_URL=smtps://user:pass@host:465and installnodemailer. - Send from server code only:
import { sendEmail } from './lib/email/index.js'; await sendEmail('welcome', { to: user.email, props: { name: user.name, appUrl: 'https://app.example.com' } }); - With
@core/auth: sendwelcomeafter the first login (when the user was just created). - Verify: run the app without
RESEND_API_KEYand check the console output.
Conventions
- New template: create
templates/<name>.tsexporting{ subject(props), render(props) }built withcreateElement as h(no JSX, so it works with anyjsxImportSource), then add it totemplatesandTemplatePropsinsend.ts. TypeScript then enforces its props everywhere. - Amounts in minor units (cents); links absolute (
https://…). - Keep
sendEmailcalls out of request hot paths when possible (after the response, or in a job).
Don't
- Don't send from the browser or expose
RESEND_API_KEYto client code. - Don't interpolate untrusted HTML into templates; pass plain strings (React escapes them).
- Don't log full email bodies in production (they may contain sign-in links).
# @core/email — rules for AI agents
## Purpose
Transactional email with typed templates: `sendEmail('welcome', { to, props })`. Providers: Resend (default), SMTP
(optional, via `nodemailer`) and a console provider for development. Templates use React Email. No marketing lists,
no queues, no tracking pixels.
## Map
- `index.ts` — public API: `sendEmail`, `renderEmail`, `setEmailProvider`, provider factories, `TemplateProps`.
- `send.ts` — the template registry (`templates`) and `sendEmail`.
- `templates/*.ts` — `welcome`, `magicLink`, `receipt`, plus the shared `layout.ts`.
- `providers.ts` — `EmailProvider` interface and implementations.
## Integration
1. Env: `EMAIL_FROM` (`"App <hello@yourdomain.com>"`) and `RESEND_API_KEY` (verify the domain in Resend first).
Without `RESEND_API_KEY`, outside production, emails are printed to the console.
`@types/react` is only needed at build time: move it to devDependencies if GenPM added it to dependencies.
SMTP instead: `EMAIL_PROVIDER=smtp`, `SMTP_URL=smtps://user:pass@host:465` and install `nodemailer`.
2. Send from server code only:
```ts
import { sendEmail } from './lib/email/index.js';
await sendEmail('welcome', { to: user.email, props: { name: user.name, appUrl: 'https://app.example.com' } });
```
3. With `@core/auth`: send `welcome` after the first login (when the user was just created).
4. Verify: run the app without `RESEND_API_KEY` and check the console output.
## Conventions
- New template: create `templates/<name>.ts` exporting `{ subject(props), render(props) }` built with
`createElement as h` (no JSX, so it works with any `jsxImportSource`), then add it to `templates` and
`TemplateProps` in `send.ts`. TypeScript then enforces its props everywhere.
- Amounts in minor units (cents); links absolute (`https://…`).
- Keep `sendEmail` calls out of request hot paths when possible (after the response, or in a job).
## Don't
- Don't send from the browser or expose `RESEND_API_KEY` to client code.
- Don't interpolate untrusted HTML into templates; pass plain strings (React escapes them).
- Don't log full email bodies in production (they may contain sign-in links).
.genpmignore 適用後に組み込まれる正確なツリーです。固定先:
import { Heading, Section, Text } from '@react-email/components';
import { createElement as h } from 'react';
import { Layout, muted, text } from './layout.js';
export type ReceiptProps = {
number: string;
/** Importes en unidades menores (céntimos) para no perder precisión. */
items: Array<{ description: string; amount: number }>;
currency: string;
date: Date;
};
const money = (minor: number, currency: string) =>
new Intl.NumberFormat('en', { style: 'currency', currency }).format(minor / 100);
export const receipt = {
subject: (p: ReceiptProps) => `Receipt ${p.number}`,
render: (p: ReceiptProps) => {
const total = p.items.reduce((n, i) => n + i.amount, 0);
return h(
Layout,
{ preview: `Receipt ${p.number} · ${money(total, p.currency)}` },
h(Heading, { as: 'h1' }, `Receipt ${p.number}`),
h(Text, { style: muted }, p.date.toISOString().slice(0, 10)),
...p.items.map((i) => h(Section, { key: i.description }, h(Text, { style: text }, `${i.description} — ${money(i.amount, p.currency)}`))),
h(Text, { style: { ...text, fontWeight: 700 } }, `Total ${money(total, p.currency)}`),
);
},
};
このパッケージは MCP サーバーを宣言していません。
| バージョン | コミット | 公開日 | スキャン |
|---|---|---|---|
| 1.0.0 | 3e2976e | 5 時間前 | ✔ スキャン合格 |
- genpm
- なし
- npm
- @react-email/components ^1.0.12@react-email/render ^2.1.0@types/react ^19.0.0react ^19.0.0resend ^6.32.0
- 提案
- GenPM は npm コマンドを提案し、あなたが承認した場合にのみ実行します。
- スキャン
- スキャン合格 · 指摘 0 件
- コミット
- v1.0.0 → 3e2976ea815795eca662b4be29d8f552ec1e0d96 · 取得後に検証済み
- スクリプト
- なし。GenPM はパッケージのコードを実行しません。
- ライセンス
- MIT
- 報告
- 問題を見つけましたか?