Skip to content

Commit

Permalink
feat(smtp): Add hostname to SMTP (getsentry#1076)
Browse files Browse the repository at this point in the history
Fixes getsentry#1045.

Co-authored-by: William Desportes <williamdes@wdes.fr>
Co-authored-by: Chad Whitacre <chadwhitacre@sentry.io>
  • Loading branch information
3 people authored Aug 26, 2021
1 parent 674a600 commit b32de84
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion _integration-test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions sentry/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
7 changes: 7 additions & 0 deletions sentry/sentry.conf.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ def get_internal_network():

# 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 #
############
Expand Down

0 comments on commit b32de84

Please sign in to comment.