Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTPServerDisconnected: Connection unexpectedly closed: timed out #2297

Closed
arthurlogilab opened this issue Nov 12, 2015 · 9 comments

Comments

@arthurlogilab
Copy link

commented Nov 12, 2015

I get a bunch of these tracebacks, eventhough sending emails works and the test procedure via the webui works :

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/sentry/utils/safe.py", line 26, in safe_execute
    result = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/sentry/plugins/bases/notify.py", line 59, in rule_notify
    self.notify(notification)
  File "/usr/local/lib/python2.7/dist-packages/sentry/plugins/sentry_mail/models.py", line 190, in notify
    context=context,
  File "/usr/local/lib/python2.7/dist-packages/sentry/plugins/sentry_mail/models.py", line 55, in _send_mail
    return msg.send()
  File "/usr/local/lib/python2.7/dist-packages/sentry/utils/email.py", line 189, in send
    self.send_all(messages, fail_silently=fail_silently)
  File "/usr/local/lib/python2.7/dist-packages/sentry/utils/email.py", line 194, in send_all
    return connection.send_messages(messages)
  File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 94, in send_messages
    sent = self._send(message)
  File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 110, in _send
    self.connection.sendmail(from_email, recipients, message.as_bytes())
  File "/usr/lib/python2.7/smtplib.py", line 736, in sendmail
    (code, resp) = self.data(msg)
  File "/usr/lib/python2.7/smtplib.py", line 504, in data
    (code, msg) = self.getreply()
  File "/usr/lib/python2.7/smtplib.py", line 360, in getreply
    + str(e))
SMTPServerDisconnected: Connection unexpectedly closed: timed out

sentry version : Sentry 7.5.4

@dcramer

This comment has been minimized.

Copy link
Member

commented Nov 18, 2015

it sounds like this is something to do with your SMTP server not responding in a time period the backend were to expect. Not sure what we can really do about this, so going to close it out.

@dcramer dcramer closed this Nov 18, 2015

@arthurlogilab

This comment has been minimized.

Copy link
Author

commented Nov 18, 2015

I understand that this might be a problem with the STMP server not responding, but I think that this traceback should not appear in the logs, an single line ERROR log should be enough in my opinion.

@andrefreitas

This comment has been minimized.

Copy link

commented May 2, 2016

I am having the same issue. The emails are actually sent but sometimes we have timeouts (even with fast responses times). Sentry could allow to configure smtplib timeout: https://docs.python.org/2/library/smtplib.html#smtplib.SMTP

@davidmir

This comment has been minimized.

Copy link

commented Jun 7, 2017

After migrate to Sentry 8.16.0 I have started receiving this error. I'm not receiving any email from Sentry and I've configure the file with the following parameters:

mail.backend: smtp
mail.host: mysmtphost
mail.port: 25
mail.from: myfromail

I've seen the connection establishid with my SMTP server, but for some reason Sentry closes the connection... Any tips to try solve this issue?

Thanks

@ffjia

This comment has been minimized.

Copy link

commented Aug 7, 2017

@davidmir I found this article might be helpful to you: http://blog.e-shell.org/323. After increasing the timeout, my time out issue disappeared.

@Renrhaf

This comment has been minimized.

Copy link

commented Jun 4, 2018

Thanks @ffjia !
Maybe a configurable value for this timeout would be useful ?

@wavilov

This comment has been minimized.

Copy link

commented Mar 12, 2019

@davidmir I found this article might be helpful to you: http://blog.e-shell.org/323. After increasing the timeout, my time out issue disappeared.

I tried to fix that error within a hole day. Though about SMTP settings and libs, firewalls and container links and suddenly it was a simple socket timeout..

Thank you, you make my day!

@DRSchlaubi

This comment has been minimized.

Copy link

commented Mar 25, 2019

I have the same error by using Sendgrid as an email provider and I don't think that a paid service like sendgrid always has such timeouts. Anyways I tried to use the test email button inside the admin dashboard and it worked perfectly

@wangy8961

This comment has been minimized.

Copy link

commented Apr 15, 2019

@DRSchlaubi check out this post: http://www.madmalls.com/blog/post/smtphandler-send-error-email/
I personally tested it, it’s real and effective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.