Comprehensive email system with Handlebars templates, internationalization support, and automated delivery for authentication workflows.
server/services/email/
├── config.ts # Email configuration and routes
├── mailer.ts # Nodemailer setup and sending logic
├── template-renderer.ts # Handlebars template rendering
└── anti-spam.ts # Rate limiting and spam protection
server/templates/emails/
├── base.hbs # Base email template layout
├── footer.hbs # Common email footer
├── verification.hbs # Email verification template
└── passwordReset.hbs # Password reset template
Configuration: See .env.example for complete email configuration including SMTP settings, authentication, and sender information.
Implementation: See server/services/email/config.ts for email route configuration and base URL handling.
Implementation: See server/services/email/template-renderer.ts for Handlebars template rendering with i18n support.
Features:
- ✅ Handlebars templates with partials support
- ✅ Internationalization with dynamic locale loading
- ✅ Responsive design with email-safe HTML/CSS
- ✅ Consistent branding across all templates
Template: See server/templates/emails/verification.hbs for email verification template.
Usage: Automatically sent during user registration process.
Template: See server/templates/emails/passwordReset.hbs for password reset template.
Usage: Sent when users request password reset via forgot password flow.
Implementation: See server/services/email.service.ts for email sending functions with template integration.
Methods:
sendVerificationEmail()- Send verification email to new userssendPasswordResetEmail()- Send password reset link
Implementation: See server/services/email/mailer.ts for Nodemailer configuration and sending logic.
Implementation: See server/services/email/anti-spam.ts for rate limiting and abuse prevention.
Features:
- ✅ Rate limiting per email address and IP
- ✅ Token expiration for security
- ✅ Email validation before sending
Implementation: Email addresses are validated using Zod schemas before sending.
Implementation: Templates support multiple languages with automatic locale detection from user preferences.
Locales: See i18n/locales/*/email.json for email content translations.
Implementation: See server/api/auth/ routes for email service integration in registration and password reset flows.
Implementation: Email service includes comprehensive error handling for delivery failures and configuration issues.
- ✅ Template-based emails with Handlebars
- ✅ Multi-language support with i18n
- ✅ Responsive design for all devices
- ✅ Anti-spam protection with rate limiting
- ✅ Secure token handling for verification
- ✅ SMTP configuration flexibility
- ✅ Error handling and logging