Overview
Concordia uses nodemailer for email delivery with support for multiple SMTP providers. The email system handles authentication flows (email verification, password reset) and can be extended for notifications.SMTP Service Architecture
The SMTP service (src/lib/smtp/smtp.ts) provides:
- Multi-provider support - Pre-configured for 10+ popular providers
- Connection pooling - Efficient email delivery with rate limiting
- Error classification - Distinguishes retryable vs permanent failures
- Validation - Email address and content validation
- Mock mode - Testing without sending real emails
Environment Configuration
Add SMTP settings to your.env file:
.env
Supported Providers
Concordia includes pre-configured settings for these providers:List All Providers
View all supported providers:Provider Setup
Option 1: Use Provider Preset
SetSMTP_PROVIDER to auto-configure:
.env
Option 2: Manual Configuration
Override individual settings:.env
Advanced Settings
Connection Pooling
Optimize delivery with connection pooling:.env
SSL/TLS Configuration
.env
Most modern providers use port 587 with STARTTLS. The service automatically configures
requireTLS based on the provider preset.Testing Email Configuration
Connection Test
Verify SMTP configuration:- Provider name and server
- Connection status (secure, TLS, pool)
- Connection test result
Send Test Email
Send a test message:Test Output Example
Email Service Usage
Basic Email Sending
Batch Email Sending
Send multiple emails with concurrency control:Error Handling
The service classifies errors:Authentication Emails
Concordia uses Better Auth for authentication, which integrates with the SMTP service for:- Email verification - Confirm user email addresses
- Password reset - Send reset links
- Magic links - Passwordless login (if configured)
Email Templates
Auth emails use Better Auth’s built-in templates. Customize them in your auth configuration:Provider-Specific Notes
Gmail
.env
Resend
Resend offers both API and SMTP. For SMTP:.env
Resend requires domain verification before sending. Add DNS records in your Resend dashboard.
SendGrid
.env
AWS SES
.env
AWS SES starts in sandbox mode. Request production access to send to unverified addresses.
Mock Mode (Testing)
Disable real email sending during development:.env
- SMTP service initializes but doesn’t send real emails
- Logs show “Mode MOCK activé”
- Perfect for running tests without email side effects
Troubleshooting
Authentication Failed
- Verify
SMTP_USERandSMTP_PASSare correct - Check if provider requires app-specific passwords (Gmail)
- Ensure account isn’t locked or suspended
- For IONOS: The service automatically uses
authMethod: 'LOGIN'
Connection Timeout
- Check firewall allows outbound SMTP (ports 587/465)
- Verify
SMTP_HOSTis correct - Try alternate port (587 vs 465)
- Check if your hosting blocks SMTP
Rate Limit Exceeded
- Reduce
SMTP_RATE_LIMITin .env - Increase
SMTP_RATE_DELTAto slow sending - Upgrade provider plan for higher limits
- Use
sendBatch()with lower concurrency
SSL/TLS Errors
- For port 587: Set
SMTP_SECURE=false - For port 465: Set
SMTP_SECURE=true - Check provider documentation for correct settings
Production Checklist
Configure credentials
Add
SMTP_PROVIDER, SMTP_USER, SMTP_PASS, and SMTP_FROM to production environment.Next Steps
Database Setup
Configure PostgreSQL for production
Hosting
Deploy your application to production