Overview
TrailBase provides built-in email functionality for sending transactional emails like verification emails, password resets, and custom notifications. Configure SMTP or use the local sendmail transport.Configuration
SMTP Configuration
Configure SMTP in yourconfig.textproto:
Encryption Options
Local Sendmail
If SMTP is not configured, TrailBase falls back to local sendmail:Built-in Email Templates
TrailBase includes default templates for common emails:Email Verification
Sent when users register with email/password:Password Reset
Sent when users request password reset:Change Email Address
Sent when users change their email:Custom Templates
Override default templates in your configuration:Template Variables
Available variables in templates:{APP_NAME}- Application name from config{EMAIL}- User’s email address{VERIFICATION_URL}- Complete verification URL{SITE_URL}- Site URL from config{CODE}- Verification code
Sending Custom Emails
From Rust
Email Implementation
Fromcrates/core/src/email.rs:
Common SMTP Providers
Gmail
Gmail App Passwords: Generate an app-specific password at myaccount.google.com/apppasswords
SendGrid
Mailgun
AWS SES
Postmark
Email in WASM Components
Direct email sending is not currently available in WASM components. Instead, queue email jobs in the database and process them with a scheduled job.
Email Queue Schema
Error Handling
Rate Limiting
Monitoring
Log Email Activity
Track Delivery
Best Practices
1
Use app-specific passwords
Never use your main account password for SMTP. Generate app-specific passwords.
2
Set proper sender info
Configure
sender_address and sender_name to avoid spam filters:3
Configure SPF and DKIM
Set up email authentication records for your domain to improve deliverability.
4
Handle bounces
Monitor bounce rates and remove invalid addresses from your lists.
5
Rate limit sends
Respect SMTP provider limits. Use queues for bulk emails.
6
Test in development
Use services like Mailhog or MailCatcher for testing.
Testing Emails
Development Setup
Use Mailhog for local testing:Next Steps
Jobs Scheduler
Send scheduled emails
Custom Endpoints
Create email triggers
OAuth Providers
Configure authentication
Server-Side Rendering
Generate HTML emails