| name | email-transactional |
| description | Wire up transactional email for any app using Resend, Postmark, useSend, or Plunk. Sets up templates for welcome, password reset, notifications, and digests. Handles domain verification, deliverability, and unsubscribe. Use when the app needs to send emails to users. |
Email Transactional
You are wiring up transactional email end-to-end. Work through each phase in order.
Email types: {{args}}
Phase 1: Interview
Ask the user (combine related questions):
- Provider: Which provider?
- From address: What sending domain? Is it already verified with the provider?
- Email types: Which of these are needed: welcome, email verification, password reset, notification, weekly digest, billing receipt, team invitation?
- Templates: Plain text only, or styled HTML? React Email or MJML for templating?
- Stack: Framework and language?
Phase 2: Explore
Spawn 2 parallel subagents:
| Subagent | Focus |
|---|
| 1 | Auth flows (signup, password reset), notification trigger points in the codebase |
| 2 | Existing email code, env vars, any current email setup |
Phase 3: Provider Setup
Detect the package manager once (used by every provider below):
command -v bun >/dev/null 2>&1 && PM=bun || (command -v pnpm >/dev/null 2>&1 && PM=pnpm || PM=npm)
Resend (CLI-driven)
irm https://resend.com/install.ps1 | iex
curl -fsSL https://resend.com/install.sh | bash
resend login
resend domains create --name mail.yourdomain.com --region us-east-1
resend domains list
resend domains verify <id>
resend api-keys create --name "Production" --permission full_access
Install SDK: $PM add resend
Set RESEND_API_KEY in env vars.
Postmark
Install SDK: $PM add postmark
- Create a Postmark account and a Server
- Add and verify your sending domain in the Postmark dashboard (SPF, DKIM records)
- Set
POSTMARK_API_KEY (Server API token) in env vars
useSend (self-hosted)
Deploy via Docker or Railway (one-click): see https://docs.usesend.com
Install SDK: $PM add usesend-js
Set USESEND_API_KEY and USESEND_BASE_URL in env vars.
Plunk (self-hosted)
docker pull useplunk/plunk
Install SDK: $PM add @plunk/node
Set PLUNK_SECRET_KEY and PLUNK_BASE_URL in env vars.
DNS Records (all providers)
Guide the user to add these DNS records for the sending domain:
- SPF:
v=spf1 include:<provider-include> ~all
- DKIM: TXT record provided by the provider dashboard
- DMARC:
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
Phase 4: Template Setup
Use React Email (default) for HTML templates:
$PM add @react-email/components react-email
Create emails/ directory with one file per template. Each template:
- Uses
<Html>, <Head>, <Body>, <Container> from @react-email/components
- Is mobile-responsive
- Has a plain-text fallback
- Matches the app's brand (colors, fonts, logo)
- Includes a footer with unsubscribe link (required for bulk emails; best practice for all)
Phase 5: Implement Email Functions
Create a shared sendEmail(to, template, data) utility that:
- Renders the React Email template to HTML
- Calls the provider API with from, to, subject, html, text
- Logs the result (success or error) with the user ID
- Never throws: catches errors and reports to error tracking
For each email type, create a typed wrapper:
sendWelcomeEmail(user: { email, name })
sendPasswordResetEmail(user: { email }, resetUrl: string)
sendNotificationEmail(user: { email }, notification: Notification)
Wire each wrapper to the correct trigger point in the codebase.
Phase 6: Deliverability
Phase 7: Verify
Completion Report
- Provider configured and domain verified
- Templates created (list)
- Send functions wired to trigger points (list with file locations)
- Deliverability checks passed
- Env vars required (names only)