Email System
The Email System decouples the intent to send an email from the actual template implementation.
EmailRegistry
Section titled “EmailRegistry”Modules register React components to handle specific email “intents” (e.g., user:welcome).
Registering a Template
Section titled “Registering a Template”import { EmailRegistry } from '@/lib/email/email-registry';import WelcomeEmail from './WelcomeEmail';
EmailRegistry.register('user:welcome', WelcomeEmail);Sending an Email
Section titled “Sending an Email”The sender renders the template by ID.
import { EmailRegistry } from '@/lib/email/email-registry';import { sendEmail } from '@/lib/email/email-sender';
const html = await EmailRegistry.render('user:welcome', { name: 'Alice' });