Email Configuration
Flo supports multiple email providers for sending transactional emails (registration confirmations, OTP codes, booking notifications, newsletters).
Supported Providers
Cloudflare Email Routing (Recommended)
Send from your own domain with no verification required.
Setup:
- Go to Cloudflare Dashboard > your domain > Email > Email Routing > SMTP Credentials
- Create SMTP credentials (username + auto-generated password)
Configuration in .env:
EMAIL_SENDER_EMAIL_PROVIDER=Cloudflare
EMAIL_SENDER_EMAIL_USERNAME=newsletter
EMAIL_SENDER_EMAIL_ALIAS=newsletter@yourdomain.com
EMAIL_SENDER_EMAIL_PSW=your-cloudflare-smtp-password
Provider config in appsettings.json:
{
"Name": "Cloudflare",
"Host": "route3.mx.cloudflare.net",
"Port": 587,
"EnableSsl": false
}
Gmail with Alias
Use Gmail's "Send As" feature to send from a custom domain.
Prerequisites:
- 2FA enabled on the Gmail account
- App Password generated (not regular password)
- Gmail "Send As" alias configured and verified
Configuration in .env:
EMAIL_SENDER_EMAIL_PROVIDER=Gmail
EMAIL_SENDER_EMAIL_USERNAME=info@gmail.com
EMAIL_SENDER_EMAIL_ALIAS=newsletter@yourdomain.com
EMAIL_SENDER_EMAIL_PSW=your-gmail-app-password
Setting up Gmail "Send As":
- Gmail Settings > Accounts and Import > "Send mail as" > Add another email address
- Enter the alias email, uncheck "Treat as an alias"
- Complete email or DNS verification
- Optionally set as default sender
Custom SMTP
For other providers (SendGrid, Mailgun, Amazon SES):
EMAIL_SENDER_EMAIL_PROVIDER=Smtp
EMAIL_SENDER_SMTP_HOST=smtp.example.com
EMAIL_SENDER_SMTP_PORT=587
EMAIL_SENDER_EMAIL_USERNAME=your-username
EMAIL_SENDER_EMAIL_ALIAS=sender@yourdomain.com
EMAIL_SENDER_EMAIL_PSW=your-password
Email Templates
Flo uses MJML for responsive email templates. Templates are brand-specific:
- Header logo changes per brand (Flo vs Respirastudio)
- Color scheme matches brand theme
- Customer name from
FLO_CUSTOMER_NAME_IT/FLO_CUSTOMER_NAME_EN
Testing
Verify Configuration on VPS
# Check environment variables
sudo docker exec flo env | grep EMAIL
# Restart container after changes
sudo docker restart flo
# Monitor logs for email sending
sudo docker logs -f flo
Expected Email Headers
From: newsletter@yourdomain.com
Reply-To: newsletter@yourdomain.com
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Emails show Gmail address as sender | Gmail alias not verified | Complete "Send As" verification |
| SMTP authentication failed | Wrong App Password or 2FA not enabled | Generate new App Password with 2FA |
| Container ignores new env vars | Env loaded at container start | Restart: sudo docker restart flo |
Code Reference
| File | Purpose |
|---|---|
Flo.BE/Services/EmailSender/Core/EmailMessageFactory.cs | Email construction with alias support |
Flo.BE/Services/EmailSender/EmailSenderService.cs | SMTP sending logic |
compose.yaml | Docker environment variable mapping |