After the self-built sentry, you have configured the mail service, but you still can't get the verification email?

problem description

I have configured the mail server in config.yml

mail.backend: "smtp"  -sharp Use dummy if you want to disable email entirely
mail.host: "smtp.exmail.qq.com"
mail.port: 587
mail.username: ""
mail.password: ""
mail.use-tls: true
-sharp The email address to send on behalf of
mail.from: ""

and send a test email, I also received

clipboard.png

clipboard.png

clipboard.png

is there something I haven"t configured yet?
took a look at smtp service"s log

 290 Connecting to gmail-smtp-in.l.google.com [2404:6800:4008:c07::1b]:25 ... failed: Cannot assign requested address
smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=gmail-smtp-in.l.google.com [2404:6800:4008:c07::1b] Cannot assign requested address
smtp_1       |   290 Connecting to gmail-smtp-in.l.google.com [108.177.97.26]:25 ... failed: Connection timed out (timeout=5m)
smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=gmail-smtp-in.l.google.com [108.177.97.26] Connection timed out
smtp_1       |   290 Connecting to alt1.gmail-smtp-in.l.google.com [2607:f8b0:4003:c19::1a]:25 ... failed: Cannot assign requested address
smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=alt1.gmail-smtp-in.l.google.com [2607:f8b0:4003:c19::1a] Cannot assign requested address
smtp_1       |   290 Connecting to alt1.gmail-smtp-in.l.google.com [209.85.235.26]:25 ... failed: Connection timed out (timeout=5m)
smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=alt1.gmail-smtp-in.l.google.com [209.85.235.26] Connection timed out
smtp_1       |   290 Connecting to alt2.gmail-smtp-in.l.google.com [2607:f8b0:4001:c1d::1b]:25 ... failed: Cannot assign requested address
smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=alt2.gmail-smtp-in.l.google.com [2607:f8b0:4001:c1d::1b] Cannot assign requested address
smtp_1       |   290 Connecting to alt3.gmail-smtp-in.l.google.com [2607:f8b0:4002:c08::1a]:25 ... failed: Cannot assign requested address
smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=alt3.gmail-smtp-in.l.google.com [2607:f8b0:4002:c08::1a] Cannot assign requested address
smtp_1       |   290 Connecting to alt4.gmail-smtp-in.l.google.com [2607:f8b0:400d:c0e::1a]:25 ... failed: Cannot assign requested address
smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=alt4.gmail-smtp-in.l.google.com [2607:f8b0:400d:c0e::1a] Cannot assign requested address
smtp_1       |   289 LOG: MAIN
smtp_1       |   289   == energy3456789@gmail.com R=dnslookup T=remote_smtp defer (99): Cannot assign requested address
Aug.11,2021

in fact, for this problem, just add environment variables to docker-compose.yml :

version: '3.4'

x-defaults: &defaults
  restart: unless-stopped
  build: .
  depends_on:
    - redis
    - postgres
    - memcached
    - smtp

  environment:
    -sharp Run `docker-compose run web config generate-secret-key`
    -sharp to get the SENTRY_SECRET_KEY value.
    SENTRY_SECRET_KEY: '1o-sqivmbumzrgzyx@wgn3&9l2)xvxktgr+t-o9%9d0@=de&27'
    SENTRY_MEMCACHED_HOST: memcached
    SENTRY_REDIS_HOST: redis
    SENTRY_POSTGRES_HOST: postgres
    -sharp 
    SENTRY_SERVER_EMAIL: 'your_username'
    SENTRY_EMAIL_HOST: 'smtp.exmail.qq.com'
    SENTRY_EMAIL_PORT: 587
    SENTRY_EMAIL_USER: 'your_username'
    SENTRY_EMAIL_PASSWORD: '********'
    SENTRY_EMAIL_USE_TLS: 'true'
    ....
    
< H2 > I found that both verification emails and exception notification emails are sent through worker this Service < / H2 >. < H2 > the following answers are not up-to-date, but reflect my solution process < / H2 >

I looked at the log carefully yesterday and found that the verification email was sent through smtp this Service, and then I looked at its log:

smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=gmail-smtp-in.l.google.com [2404:6800:4008:c07::1b] Cannot assign requested address
smtp_1       |   290 Connecting to gmail-smtp-in.l.google.com [108.177.97.26]:25 ... failed: Connection timed out (timeout=5m)
smtp_1       |   290 LOG: MAIN
smtp_1       |   290   H=gmail-smtp-in.l.google.com [108.177.97.26] Connection timed out
smtp_1       |   290 Connecting to alt1.gmail-smtp-in.l.google.com [2607:f8b0:4003:c19::1a]:25 ... failed: Cannot assign requested address

found that this service does not use the configuration in config.yml , because the smtp server I configured is smtp.exmail.qq.com of Tencent, and the port is 587
. I have added mount

to web this Service.
web:
    <<: *defaults
    ports:
      - '127.0.0.1:9000:9000'
    volumes:
      - ./config.yml:/etc/sentry/config.yml

web, the Service, that is, the web interface used, has read the configuration correctly, which means that the problem lies in the smtp this Service.
I took a look at its image, using tianon/exim4 this image, its entry shell

-sharp!/bin/bash
set -e

opts=(
    dc_local_interfaces '0.0.0.0 ; ::0'
    dc_other_hostnames ''
    dc_relay_nets '0.0.0.0/0'
)

if [ "$GMAIL_USER" -a "$GMAIL_PASSWORD" ]; then
    -sharp see https://wiki.debian.org/GmailAndExim4
    opts+=(
        dc_eximconfig_configtype 'smarthost'
        dc_smarthost 'smtp.gmail.com::587'
    )
    echo "*.google.com:$GMAIL_USER:$GMAIL_PASSWORD" > /etc/exim4/passwd.client
else
    opts+=(
        dc_eximconfig_configtype 'internet'
    )
fi

set-exim4-update-conf "${opts[@]}"

if [ "$(id -u)" = '0' ]; then
    mkdir -p /var/spool/exim4 /var/log/exim4 || :
    chown -R Debian-exim:Debian-exim /var/spool/exim4 /var/log/exim4 || :
fi

exec "$@"

queried. This image uses Exim4 on debian to send mail. Some of its configurations

dc_eximconfig_configtype='internet'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'

dc_eximconfig_configtype this parameter, if internet is written, smtp will be queried automatically. That's why google's smtp server, will be used in smtp server's log. If you want to write a fixed configuration, you should change dc_eximconfig_configtype to smarthost, and then configure dc_smarthost to your smtp server,. Notice that there are two colons in it, and you also need to write the corresponding account password in the password file / etc/exim4/passwd.client, such as

.
*.google.com:your_user_name:your_password

.google.com is just a wildcard. In fact, these things can be seen from this shell

.
if [ "$GMAIL_USER" -a "$GMAIL_PASSWORD" ]; then
    -sharp see https://wiki.debian.org/GmailAndExim4
    opts+=(
        dc_eximconfig_configtype 'smarthost'
        dc_smarthost 'smtp.gmail.com::587'
    )
    echo "*.google.com:$GMAIL_USER:$GMAIL_PASSWORD" > /etc/exim4/passwd.client
else

for all, I have temporarily solved the problem at present, that is, change the docker-entrypoint.sh and mount it into the container. Remember to assign x permission. The best way for
is to change the image so that you can identify the environment variables

.

check whether there are any errors in the sentry system monitoring


you can also receive email notifications when you do not verify your mailbox. For more information, please see here

.

clipboard.png

Menu