feat(smtp): Add hostname to SMTP (#1076)

Fixes #1045.

Co-authored-by: William Desportes <williamdes@wdes.fr>
Co-authored-by: Chad Whitacre <chadwhitacre@sentry.io>
This commit is contained in:
Burak Yigit Kaya 2021-08-26 17:40:22 +03:00 committed by GitHub
parent 674a600770
commit b32de84d31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 2 deletions

4
.env
View File

@ -3,8 +3,10 @@ SENTRY_EVENT_RETENTION_DAYS=90
# You can either use a port number or an IP:PORT combo for SENTRY_BIND
# See https://docs.docker.com/compose/compose-file/#ports for more
SENTRY_BIND=9000
# Set SENTRY_MAIL_HOST to a valid FQDN (host/domain name) to be able to send emails!
# SENTRY_MAIL_HOST=example.com
SENTRY_IMAGE=getsentry/sentry:nightly
SNUBA_IMAGE=getsentry/snuba:nightly
RELAY_IMAGE=getsentry/relay:nightly
SYMBOLICATOR_IMAGE=getsentry/symbolicator:nightly
WAL2JSON_VERSION=latest
WAL2JSON_VERSION=latest

View File

@ -82,7 +82,7 @@ echo "${_endgroup}"
echo "${_group}Running moar tests !!!"
# Set up initial/required settings (InstallWizard request)
sentry_api_request "internal/options/?query=is:required" -X PUT --data '{"mail.use-tls":false,"mail.username":"","mail.port":25,"system.admin-email":"ben@byk.im","mail.password":"","mail.from":"root@localhost","system.url-prefix":"'"$SENTRY_TEST_HOST"'","auth.allow-registration":false,"beacon.anonymous":true}' > /dev/null
sentry_api_request "internal/options/?query=is:required" -X PUT --data '{"mail.use-tls":false,"mail.username":"","mail.port":25,"system.admin-email":"ben@byk.im","mail.password":"","system.url-prefix":"'"$SENTRY_TEST_HOST"'","auth.allow-registration":false,"beacon.anonymous":true}' > /dev/null
SENTRY_DSN=$(sentry_api_request "projects/sentry/internal/keys/" | awk 'BEGIN { RS=",|:{\n"; FS="\""; } $2 == "public" && $4 ~ "^http" { print $4; exit; }')
# We ignore the protocol and the host as we already know those

View File

@ -63,6 +63,7 @@ x-sentry-defaults: &sentry_defaults
# Leaving the value empty to just pass whatever is set
# on the host system (or in the .env file)
SENTRY_EVENT_RETENTION_DAYS:
SENTRY_MAIL_HOST:
volumes:
- "sentry-data:/data"
- "./sentry:/etc/sentry"
@ -92,6 +93,7 @@ services:
smtp:
<<: *restart_policy
image: tianon/exim4
hostname: ${SENTRY_MAIL_HOST:-}
volumes:
- "sentry-smtp:/var/spool/exim4"
- "sentry-smtp-log:/var/log/exim4"

View File

@ -14,6 +14,12 @@ mail.host: 'smtp'
# mail.password: ''
# mail.use-tls: false
# mail.use-ssl: false
# NOTE: The following 2 configs (mail.from and mail.list-namespace) are set
# through SENTRY_MAIL_HOST in sentry.conf.py so remove those first if
# you want your values in this file to be effective!
# The email address to send on behalf of
# mail.from: 'root@localhost'

View File

@ -228,6 +228,13 @@ SENTRY_WEB_OPTIONS = {
# End of SSL/TLS settings
########
# Mail #
########
SENTRY_OPTIONS["mail.list-namespace"] = env('SENTRY_MAIL_HOST', 'localhost')
SENTRY_OPTIONS["mail.from"] = f"sentry@{SENTRY_OPTIONS['mail.list-namespace']}"
############
# Features #
############