[GH-ISSUE #425] Issues with using Sendgrid SMTP API #318

Closed
opened 2026-02-25 23:42:00 +03:00 by kerem · 6 comments
Owner

Originally created by @dalanmiller on GitHub (Sep 10, 2020).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/425

Expected Behavior

Expecting to send email with login link

Current Behavior

SMTP settings seem to error out, unclear what is causing the issue but I'm unsure any information is returned from the inability to connect.

healthchecks            | Traceback (most recent call last):
healthchecks            |   File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
healthchecks            |     self.run()
healthchecks            |   File "./hc/lib/emails.py", line 23, in run
healthchecks            |     msg.send()
healthchecks            |   File "/usr/lib/python3.8/site-packages/django/core/mail/message.py", line 276, in send
healthchecks            |     return self.get_connection(fail_silently).send_messages([self])
healthchecks            |   File "/usr/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
healthchecks            |     new_conn_created = self.open()
healthchecks            |   File "/usr/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 69, in open
healthchecks            |     self.connection.login(self.username, self.password)
healthchecks            |   File "/usr/lib/python3.8/smtplib.py", line 723, in login
healthchecks            |     (code, resp) = self.auth(
healthchecks            |   File "/usr/lib/python3.8/smtplib.py", line 635, in auth
healthchecks            |     (code, resp) = self.docmd("AUTH", mechanism + " " + response)
healthchecks            |   File "/usr/lib/python3.8/smtplib.py", line 425, in docmd
healthchecks            |     return self.getreply()
healthchecks            |   File "/usr/lib/python3.8/smtplib.py", line 398, in getreply
healthchecks            |     raise SMTPServerDisconnected("Connection unexpectedly closed")
healthchecks            | smtplib.SMTPServerDisconnected: Connection unexpectedly closed

This was working for me in previous image versions. It is unclear to me what has changed.

Steps to Reproduce

I'm currently Sendgrid's SMTP API and have set the following environment variables:

     - DEFAULT_FROM_EMAIL="<email>"
      - EMAIL_HOST=smtp.sendgrid.net
      - EMAIL_PORT=587
      - EMAIL_HOST_USER=apikey
      - EMAIL_HOST_PASSWORD=<api key>
      - EMAIL_USE_TLS=True
Originally created by @dalanmiller on GitHub (Sep 10, 2020). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/425 ## Expected Behavior Expecting to send email with login link ## Current Behavior SMTP settings seem to error out, unclear what is causing the issue but I'm unsure any information is returned from the inability to connect. ``` healthchecks | Traceback (most recent call last): healthchecks | File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner healthchecks | self.run() healthchecks | File "./hc/lib/emails.py", line 23, in run healthchecks | msg.send() healthchecks | File "/usr/lib/python3.8/site-packages/django/core/mail/message.py", line 276, in send healthchecks | return self.get_connection(fail_silently).send_messages([self]) healthchecks | File "/usr/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages healthchecks | new_conn_created = self.open() healthchecks | File "/usr/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 69, in open healthchecks | self.connection.login(self.username, self.password) healthchecks | File "/usr/lib/python3.8/smtplib.py", line 723, in login healthchecks | (code, resp) = self.auth( healthchecks | File "/usr/lib/python3.8/smtplib.py", line 635, in auth healthchecks | (code, resp) = self.docmd("AUTH", mechanism + " " + response) healthchecks | File "/usr/lib/python3.8/smtplib.py", line 425, in docmd healthchecks | return self.getreply() healthchecks | File "/usr/lib/python3.8/smtplib.py", line 398, in getreply healthchecks | raise SMTPServerDisconnected("Connection unexpectedly closed") healthchecks | smtplib.SMTPServerDisconnected: Connection unexpectedly closed ``` This was working for me in previous image versions. It is unclear to me what has changed. ## Steps to Reproduce I'm currently Sendgrid's SMTP API and have set the following environment variables: ``` - DEFAULT_FROM_EMAIL="<email>" - EMAIL_HOST=smtp.sendgrid.net - EMAIL_PORT=587 - EMAIL_HOST_USER=apikey - EMAIL_HOST_PASSWORD=<api key> - EMAIL_USE_TLS=True ```
kerem closed this issue 2026-02-25 23:42:01 +03:00
Author
Owner

@cuu508 commented on GitHub (Sep 11, 2020):

Does this happen every time or was this an one-off error?

For sending emails on the hosted service, I'm using SMTP over port 587 as well, but the provider is AWS SES. I've seen a "Connection unexpectedly closed" error once or twice over the last few months.

<!-- gh-comment-id:691014495 --> @cuu508 commented on GitHub (Sep 11, 2020): Does this happen every time or was this an one-off error? For sending emails on the hosted service, I'm using SMTP over port 587 as well, but the provider is AWS SES. I've seen a "Connection unexpectedly closed" error once or twice over the last few months.
Author
Owner

@dalanmiller commented on GitHub (Sep 12, 2020):

@cuu508 this is now happening every time for me.

<!-- gh-comment-id:691393261 --> @dalanmiller commented on GitHub (Sep 12, 2020): @cuu508 this is now happening every time for me.
Author
Owner

@ghost commented on GitHub (Sep 15, 2020):

I'm having an issue pinging from Azure. Azure is telling me that HC is not supporting TLS 1.2.

Any thoughts. Thanks. Jerry

<!-- gh-comment-id:692868264 --> @ghost commented on GitHub (Sep 15, 2020): I'm having an issue pinging from Azure. Azure is telling me that HC is not supporting TLS 1.2. Any thoughts. Thanks. Jerry
Author
Owner

@cuu508 commented on GitHub (Sep 15, 2020):

Hi @jerrylanejohns – that is a separate issue. If you are using the hosted service please contact me at contact@healthchecks.io about it!

<!-- gh-comment-id:692918112 --> @cuu508 commented on GitHub (Sep 15, 2020): Hi @jerrylanejohns – that is a separate issue. If you are using the hosted service please contact me at contact@healthchecks.io about it!
Author
Owner

@nimamahmoudi commented on GitHub (Oct 2, 2020):

I have the same issue as well, any fixes?

<!-- gh-comment-id:702983767 --> @nimamahmoudi commented on GitHub (Oct 2, 2020): I have the same issue as well, any fixes?
Author
Owner

@cuu508 commented on GitHub (Oct 5, 2020):

FWIW I just signed up for a new Sendgrid account, verified a domain, and sent an email using their SMTP relay – the email arrived.

@dalanmiller, @nimamahmoudi I would check the following:

  • Do emails work if you use SMTP credentials from a different provider (i.e., is there a problem with any SMTP delivery, or specifically with Sendgrid)?
  • Do Sendgrid's SMTP credentials work from different environments, for example from Thunderbird?

If the problem seems Sendgrid-specific, please contact their support.

Otherwise, check if your hosting provider is blocking port 587.

<!-- gh-comment-id:703475777 --> @cuu508 commented on GitHub (Oct 5, 2020): FWIW I just signed up for a new Sendgrid account, verified a domain, and sent an email using their SMTP relay – the email arrived. @dalanmiller, @nimamahmoudi I would check the following: * Do emails work if you use SMTP credentials from a different provider (i.e., is there a problem with any SMTP delivery, or specifically with Sendgrid)? * Do Sendgrid's SMTP credentials work from different environments, for example from Thunderbird? If the problem seems Sendgrid-specific, please contact their support. Otherwise, check if your hosting provider is blocking port 587.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#318
No description provided.