Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SMTPServerDisconnected: Connection unexpectedly closed: timed out

After running the sentry on-premise docker container (version 8.20) and passing in the following eviromental variables:

-e SENTRY_EMAIL_HOST="smtp.sendgrid.net"
-e SENTRY_EMAIL_PORT=465
-e SENTRY_EMAIL_USE_TLS="True"
-e SENTRY_EMAIL_USER="apikey"
-e SENTRY_EMAIL_PASSWORD= '****'

I am receiving the following:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/tasks/base.py", line 54, in _wrapped
    result = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/tasks/email.py", line 76, in send_email
    send_messages([message])
  File "/usr/local/lib/python2.7/site-packages/sentry/utils/email.py", line 415, in send_messages
    sent = connection.send_messages(messages)
  File "/usr/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 87, in send_messages
    new_conn_created = self.open()
  File "/usr/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 48, in open
    local_hostname=DNS_NAME.get_fqdn())
  File "/usr/local/lib/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/local/lib/python2.7/smtplib.py", line 317, in connect
    (code, msg) = self.getreply()
  File "/usr/local/lib/python2.7/smtplib.py", line 365, in getreply
    + str(e))
SMTPServerDisconnected: Connection unexpectedly closed: timed out

Any one have an idea what might be the cause?

like image 214
jimfromsa Avatar asked Mar 08 '23 14:03

jimfromsa


1 Answers

According to Sendgrid Documentation

You can also connect via SSL on port 465.

It seems that currently django.core.mail.backends.smtp.EmailBackend does not support sending emails over ssl and only TSL.

I changed the port to 587 and emails are going through as expected.

like image 67
jimfromsa Avatar answered Apr 28 '23 12:04

jimfromsa