Email

packages/email renders transactional emails and sends them over SMTP.

Template Sent when
invitation An owner or admin invites someone to an organization
reset-password Someone asks for a password reset
verify-email A user signs up

Local development

pnpm db:up starts Mailpit. Every email lands in its inbox at http://localhost:8025, nothing leaves your machine. With SMTP_URL empty, emails are printed in the API output instead.

Production

Set SMTP_URL and EMAIL_FROM. Any SMTP provider works:

# Resend
SMTP_URL=smtps://resend:re_xxx@smtp.resend.com:465
# Namecheap Private Email, Google Workspace, ...
SMTP_URL=smtps://hello%40acme.com:password@mail.privateemail.com:465
EMAIL_FROM="Acme <hello@acme.com>"

Turn on SPF and DKIM for your domain at the provider so emails don't land in spam.

Add a template

  1. Add a case to the EmailTemplate union and to renderTemplate in packages/email/src/templates.ts.
  2. Send it from the API:
import { createEmailSender, sendTemplate } from "@repo/email";
await sendTemplate(createEmailSender(), user.email, { kind: "your-template", ... });

In tests, pass an in-memory sender: createAuth({ sendEmail: async (m) => outbox.push(m) }).