Skip to main content
The Mailer plugin gives you transactional email with full type safety: write templates as React Email components, send them through Resend, and call one typed sendTemplate method from anywhere in the API. It’s a plugin — installing it merges the @ship/emails package (packages/emails) into your repo, so every template and the service itself are yours to edit.

The package

@ship/emails exports a single emailService plus the template types:
packages/emails/src/index.ts
Templates and their props are registered in template.ts — a Template union, the EmailComponent map, and a TemplateProps map that ties each template to its prop type:
packages/emails/src/template.ts
This is what makes the API end type-safe: pick template: 'verify-email' and TypeScript requires exactly VerifyEmailProps.

Sending email

Import emailService and call sendTemplate. The params are checked against the chosen template’s props:
apps/api/src/auth.ts
Under the hood sendTemplate renders the React component to HTML and hands it to Resend:
packages/emails/src/email.service.ts
With no RESEND_API_KEY, sendTemplate logs the email payload and returns null instead of sending — so local development and tests never hit Resend.

Configuration

The service is constructed from environment variables, with sensible fallbacks for the sender:
packages/emails/src/email.service.ts

Writing a template

A template is a React Email component plus an exported props interface. It composes the shared Layout and _components:
packages/emails/emails/sign-up-welcome.tsx
To add one:
1

Create the component

Add emails/<name>.tsx, exporting the component and its Props interface.
2

Register it

In src/template.ts, add the name to the Template union, the EmailComponent map, and TemplateProps.
3

Send it

emailService.sendTemplate({ template: '<name>', params: { ... } }) — typed end to end.

Local preview

React Email ships a live preview server. Run it to see your templates in the browser with hot reload:
This serves the emails/ folder at http://localhost:4000. Default prop values (like name = 'John') render so every template has realistic content without wiring up data. React Email preview
Preview renders straight from the React components, so what you see is exactly what sendTemplate produces — no separate build step.