Set up SMTP for self-hosted Sentry
Self-hosted Sentry emails issue alerts, weekly reports and the links that verify a user's email address. Outbound mail comes from the `mail.*` keys in `sentry/config.yml`, which point at the bundled `smtp` relay container until you change `mail.host`. The catch: `sentry/sentry.conf.py` builds `mail.from` from `SENTRY_MAIL_HOST`, and that wins over anything you put in `config.yml`.
Create a send-only key
In Unitpost, open Settings → SMTP and create a send-only key. Copy it now; it's shown once. Mail goes out as
sentry@plus the domain inSENTRY_MAIL_HOST, so that domain must be verified.Set the From domain in .env
sentry/sentry.conf.pysetsmail.fromtosentry@plusSENTRY_MAIL_HOST. Set that variable in the.envat the root of your self-hosted checkout to your verified domain.EnvSENTRY_MAIL_HOST=yourdomain.comWant another address, such as
alerts@yourdomain.com? Delete themail.list-namespaceandmail.fromlines under# Mail #insentry/sentry.conf.py, then setmail.frominconfig.yml.Point mail.* at Unitpost
In
sentry/config.yml, replacemail.host: 'smtp'(the bundled relay) and uncomment the connection keys.mail.use-tlsis STARTTLS on port 587 andmail.use-sslis implicit TLS on 465. The file warns they must not appear together, so uncomment only one.YAMLmail.backend: 'smtp' mail.host: 'smtp.unitpost.com' mail.port: 587 mail.username: 'unitpost' mail.password: 'pk_live_...' mail.use-tls: trueFor port 465, set
mail.port: 465andmail.use-ssl: true, and leavemail.use-tlscommented out.Rebuild and restart
The containers read
.envandconfig.ymlwhen they start. Re-run the installer from your self-hosted checkout; it rebuilds and restarts them.Shell./install.shSend a test from the admin Mail page
As a superuser, open
/manage/status/mail/on your instance. SMTP Settings lists the host, port, username and STARTTLS or SSL flag that loaded. Under Test Settings, the Send a test email button mails your own account address; find it in Unitpost Emails.If the test fails
535 5.7.8 Username must be 'unitpost'meansmail.usernameholds an email address.550 5.7.1means the From domain isn't verified, so checkSENTRY_MAIL_HOST. A hang on port 465 usually meansmail.use-tlsis set wheremail.use-sslbelongs.