Info
- Service Hub sends these emails
- Invites to an app, valid 7 days. Expired ones are deleted 30 days later
- Group invites from a group's owners, valid as long as they pick (7 days by default, up to a year), working only for the invited address and once. Sent several at a time; unused ones are deleted 30 days after they expire
- Password reset links, valid 2 hours
- Email confirmation for new password accounts, valid 2 hours. Signing in before confirming sends a new link
- Disk space alert to
ADMIN_EMAIL when the server disk is 80% full, weekly while it stays so
- Server alerts to
ADMIN_EMAIL when a monitoring alert starts, every 6 hours while it lasts
- Backup alert to
ADMIN_EMAIL when the newest database backup (the hub's or GlitchTip's) is over 8 days old, weekly until a new one is made
- All emails share one Polis layout: title, text, a button with the plain link under it, footer
- It sends over plain SMTP, so any mail provider works
- Without
SMTP_HOST and MAIL_FROM these features are off: no Invite by email or group invites by email (links still work), no Forgot your password?, no email confirmation
Setup
- Pick a provider and get its SMTP details
- Fill in
.env (on the server: SMTP_USER and SMTP_PASSWORD as GitHub secrets, the rest as GitHub variables, see Deployment): SMTP_HOST, SMTP_PORT (usually 587), SMTP_USER, SMTP_PASSWORD, MAIL_FROM, MAIL_FROM_NAME
- Restart the app, or deploy
- Port 465 uses TLS from the start, other ports upgrade with STARTTLS. With
SMTP_USER set STARTTLS is required, so the password never goes in plain text. Without it STARTTLS is used when the server offers it
Providers
- Gmail - fine to start, about 500 emails a day
- Host
smtp.gmail.com, port 587
SMTP_USER and MAIL_FROM are your Gmail address
SMTP_PASSWORD is an App Password (Google account → Security → 2-Step Verification → App passwords), not your normal password
- Mail comes from the Gmail address, not our domain
- Brevo - EU based, free plan about 300 a day, good default for our domain
- Postmark - best delivery for transactional mail, paid
- Amazon SES - cheapest at scale, more setup
- Our own domain needs its SPF, DKIM and DMARC DNS records, otherwise mail lands in spam. The provider shows the records to add
Local testing
- Local Compose runs Mailpit. The app in Docker and the Rider launch profiles (
http, https) send to it on port 1025
- Every email lands at
http://localhost:8025, nothing reaches real people
- Mailpit takes about 8 s per connection and handles them one at a time, so several emails look slower locally than they are