DO NOT upgrade any Plunk dependencies unless you’re following their official migration guide and understand the breaking changes. Upgrading without proper migration can break your email sending functionality and template rendering. The current Plunk version in the boilerplate is tested and stable.
This guide covers working with email sending using Plunk in Titan.Titan includes a complete email infrastructure that allows you to send transactional and marketing emails to your users. The system uses Plunk, a modern email service that provides beautiful email templates, reliable delivery, and detailed analytics.
You can test email functionality in your local development environment.
Set config.email.enabled to true in config.ts
Copy
// In config.tsexport const config = { // ... other config options email: { enabled: true, // Make sure this is set to true }, // ... other config options};
Add your Plunk API key to your app’s environment variables
Copy
PLUNK_API_KEY="your_plunk_api_key"
Create email templatesa. In the Plunk dashboard, go to ‘Templates’b. Create templates for each type of email you need (welcome, password reset, notifications, etc.)c. Note the template IDs for each template you create
Run your app
Copy
bun run dev
Test sending emailsYou can test sending emails using the provided utility functions:
Copy
// Example of sending an emailimport { sendEmail } from '@/lib/email';await sendEmail({ to: 'user@example.com', templateId: 'your_template_id', variables: { userName: 'John Doe', // other template variables },});