SMTP setup not working

I was trying to enable SMTP emails for the on-premise docker server I have running on EC2, for which I did the following changes in sentry/config.yml '<removed>'
mail.port: 25
mail.username: '<removed>'
mail.password: '<removed>'
mail.use-tls: true
# The email address to send on behalf of
mail.from: '<removed>'

Then I ran ./
But for some reason sentry got upgrade to 21.5 when im pretty sure it was 21.3 earlier. AFAIK, I had not done a Git pull or anything.

Regardless the service ran fine on accessing it, but I am no longer able to send events to it, i.e., any new events sent to sentry are no longer shown. I am also seeing a bunch of errors in compose logs, especially in relay, snuba-replacer, snuba-sessions-consumer, snuba-outcomes-consumer, snuba-consumer, snuba-transactions-consumer, subscription-consumer-events, subscription-consumer-transactions

Since then I have tried to git pull and install again, to update to latest version, and tried to install 21.3 again, nothing seems to work. I have also reverted config.yml to its original state and re-run installation, still Sentry does not catch errors

I actually managed to somehow solve this by pulling on master branch and running a few times, till everything fixed itself somehow.

Though I am still struggling with making SMTP emails work. I just this error.

web_1                                       | 14:12:58 [INFO] sentry.superuser: superuser.request 
            (url='http://sentry.<removed>.com/api/0/internal/mail/' method='POST' 
             ip_address='' user_id=1)
nginx_1                                     | - - [05/May/2021:14:12:58 +0000] "POST 
               /api/0/internal/mail/ HTTP/1.0" 500 42 
               "https://sentry.<removed>.com/manage/status/mail/" "Mozilla/5.0 (X11; 
                Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 
                Safari/537.36" ""

The config used is

mail.backend: 'smtp'  # Use dummy if you want to disable email entirely 'smtp' ''
mail.port: 587
mail.username: 'apikey'
mail.password: '<removed>'
#mail.use-tls: true
# The email address to send on behalf of
mail.from: '<removed>'

I manually tested from the host machine, I am able to send emails via Telnet

Can anyone help me debug this setup to get SMTP emails working?

version: 21.5.1
system: CentOS 7.9
similar error

web_1                                       | 05:51:09 [INFO] sentry.superuser: superuser.request (url='' method='POST' ip_address='' user_id=1)
nginx_1                                     | 2021/06/23 05:51:17 [error] 7#7: *382 upstream prematurely closed connection while reading response header from upstream, client:, server: , request: "POST /api/0/internal/mail/ HTTP/1.1", upstream: "", host: "", referrer: ""
nginx_1                                     | - - [23/Jun/2021:05:51:17 +0000] "POST /api/0/internal/mail/ HTTP/1.1" 502 552 "" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36" "-"