Email Services
Fluxbase includes a built-in email system for sending authentication emails (magic links, password resets, email verification) and custom transactional emails.
Overview
Section titled “Overview”The email system supports multiple providers:
- SMTP - Standard SMTP servers (Gmail, Outlook, custom servers)
- SendGrid - SendGrid API integration
- Mailgun - Mailgun API integration
- AWS SES - Amazon Simple Email Service
All providers support:
- Magic link authentication
- Email verification
- Password reset emails
- Custom HTML email templates
- Fallback to default templates
Quick Start
Section titled “Quick Start”Choose a provider:
| Provider | Best For |
|---|---|
| SMTP | Development, custom servers |
| SendGrid | Production, high volume |
| Mailgun | Production, flexibility |
| AWS SES | AWS infrastructure |
Configure (environment variables):
FLUXBASE_EMAIL_ENABLED=trueFLUXBASE_EMAIL_PROVIDER=smtp # smtp, sendgrid, mailgun, sesFLUXBASE_EMAIL_FROM_ADDRESS=noreply@yourapp.comFLUXBASE_EMAIL_FROM_NAME="Your App Name"
# SMTP exampleFLUXBASE_EMAIL_SMTP_HOST=smtp.gmail.comFLUXBASE_EMAIL_SMTP_PORT=587FLUXBASE_EMAIL_SMTP_USERNAME=your-email@gmail.comFLUXBASE_EMAIL_SMTP_PASSWORD=your-app-passwordFLUXBASE_EMAIL_SMTP_TLS=trueProvider Configuration
Section titled “Provider Configuration”FLUXBASE_EMAIL_PROVIDER=smtpFLUXBASE_EMAIL_SMTP_HOST=smtp.gmail.comFLUXBASE_EMAIL_SMTP_PORT=587FLUXBASE_EMAIL_SMTP_USERNAME=your-email@gmail.comFLUXBASE_EMAIL_SMTP_PASSWORD=your-app-passwordFLUXBASE_EMAIL_SMTP_TLS=trueCommon SMTP hosts:
| Provider | Host | Port | Notes |
|---|---|---|---|
| Gmail | smtp.gmail.com | 587 | Requires App Password |
| Outlook | smtp.office365.com | 587 | Use account password |
| Custom | mail.yourserver.com | 587 | TLS recommended |
SendGrid
Section titled “SendGrid”FLUXBASE_EMAIL_PROVIDER=sendgridFLUXBASE_EMAIL_SENDGRID_API_KEY=SG.xxxxxxxxxxxxxxxxxxxxxSetup:
- Sign up at sendgrid.com
- Settings → client keys → Create API Key (Mail Send permission)
- Verify domain: Settings → Sender Authentication → Add DNS records
Mailgun
Section titled “Mailgun”FLUXBASE_EMAIL_PROVIDER=mailgunFLUXBASE_EMAIL_MAILGUN_API_KEY=key-xxxxxxxxxxxxxxxxxxxxxFLUXBASE_EMAIL_MAILGUN_DOMAIN=mg.yourapp.comSetup:
- Sign up at mailgun.com
- Add domain: Sending → Domains → Add DNS records
- Get API key: Settings → client keys → Copy Private API key
AWS SES
Section titled “AWS SES”FLUXBASE_EMAIL_PROVIDER=sesFLUXBASE_EMAIL_SES_ACCESS_KEY=AKIAXXXXXXXXXXXXXXXXFLUXBASE_EMAIL_SES_SECRET_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXFLUXBASE_EMAIL_SES_REGION=us-east-1Setup:
- Go to SES console
- Verify email/domain
- Request production access (sandbox mode only sends to verified addresses)
- Create IAM user with
AmazonSESFullAccesspolicy
Email Templates
Section titled “Email Templates”Fluxbase includes default HTML templates for magic links, email verification, and password resets.
Custom templates:
email: magic_link_template: /path/to/magic-link.html verification_template: /path/to/verification.html password_reset_template: /path/to/password-reset.htmlTemplate variables:
{{.Link}}- Full action URL{{.Token}}- Token only
Troubleshooting
Section titled “Troubleshooting”| Issue | Solution |
|---|---|
| Emails not sending | Check logs for “Email service initialized”, verify SMTP connection with telnet smtp.gmail.com 587, confirm credentials are correct |
| Gmail “Less secure app” | Use App Password: Enable 2FA → Generate app password → Use in config |
| SendGrid 401 | Verify API key has “Mail Send” permission: Settings → client keys → Check permissions |
| Mailgun domain not verified | Add DNS records: Copy TXT/MX records → Add to DNS provider → Wait 5-10 min → Verify |
| AWS SES sandbox | In sandbox, only sends to verified addresses. Request production access or verify recipients |
| SMTP timeout | Check firewall allows port 587/465, verify host/port, try different ports, check if hosting provider blocks SMTP |
Best Practices
Section titled “Best Practices”| Practice | Description |
|---|---|
| Use environment variables | Never commit client keys/passwords to version control. Use FLUXBASE_EMAIL_* env vars |
| Verify domain | Always verify sending domain in production to improve deliverability and avoid spam |
| Separate dev/prod | Use SMTP/MailHog for development, SendGrid/Mailgun/SES for production |
| Monitor delivery | Set up webhooks to track bounces/complaints. Keep bounce rate < 5% |
| Respect rate limits | Gmail: 500/day, SendGrid: 100/day (free), Mailgun: 5k/month (free), SES: 1/sec (sandbox) |
| Handle failures | Don’t block user flows if email fails. Log errors and retry later |
| Protect credentials | Store in env vars/secrets manager, use IAM roles where possible, rotate regularly |
| Email authentication | Configure SPF, DKIM, DMARC DNS records to prevent spoofing and improve deliverability |
| Content security | Sanitize user content, use HTTPS links, include unsubscribe for marketing emails |