Codapult uses Resend for transactional email delivery and React Email for composable, type-safe email templates. Emails are sent through the background job system for reliability and non-blocking performance.
Setup
Set these environment variables in .env.local:
| Variable | Description |
|---|---|
RESEND_API_KEY | Your Resend API key from resend.com/api-keys |
EMAIL_FROM | Default sender address (e.g. Your App <[email protected]>) |
Sending Email
Use the enqueueEmail helper from @/lib/jobs to send emails via the background job system:
import { render } from '@react-email/render';
import { enqueueEmail } from '@/lib/jobs';
import { WelcomeEmail } from '@/lib/email/templates/WelcomeEmail';
const html = await render(
<WelcomeEmail userName="Jane" dashboardUrl="https://app.example.com/dashboard" />,
);
await enqueueEmail('[email protected]', 'Welcome to the team!', html);
The enqueueEmail function accepts three arguments — to, subject, and html — and dispatches a send-email background job that delivers via Resend.
Templates
Email templates live in src/lib/email/templates/ and are React components built with @react-email/components. Five templates are included out of the box (Welcome, Billing, Reset Password, Invitation, and a shared BaseLayout).
For creating new templates, the component API, and styling rules, see the dedicated Email Templates page.
Custom Sending Domains
Codapult integrates with the Resend Domains API to let you verify and manage custom sending domains directly from the admin panel.
Admin Panel
Navigate to Admin → Email Domains to:
- Add a new sending domain
- View DNS records required for verification (SPF, DKIM, DMARC)
- Check verification status
- Remove a domain
How It Works
- Add your domain in the admin panel
- Resend returns the required DNS records
- Add the DNS records to your domain provider
- Resend verifies the records automatically
- Start sending from
@yourdomain.comaddresses
Development Without Resend
When RESEND_API_KEY is not set, all email sending is skipped — the enqueueEmail function logs the email details to the console instead of sending. This lets you develop and test without a Resend account.
To test actual email delivery locally, sign up for a free Resend account and use the provided API key. The free tier allows 100 emails/day.
Bounce Handling
Resend handles bounces and complaints automatically. You can configure bounce webhooks in the Resend dashboard to receive notifications when emails bounce or are marked as spam. Codapult does not include built-in bounce handling logic — implement it based on your product's needs (e.g. disable email notifications for bouncing addresses).
Removing the Module
Email is a removable module. Use the setup wizard (npx @codapult/cli setup) to strip it, or see the Modules documentation for manual removal steps. If removed, any code that calls enqueueEmail must be updated or removed as well.