self-hosted icon indicating copy to clipboard operation
self-hosted copied to clipboard

Not able to send invite emails

Open rohitdhas opened this issue 9 months ago • 2 comments

Self-Hosted Version

24.1.0

CPU Architecture

x86_64

Docker Version

26.1.1

Docker Compose Version

v2.27.0

Steps to Reproduce

We did a clean install and followed https://develop.sentry.dev/self-hosted/email/ this doc to setup outbound emails. We have hosted this on a linode server (16GB RAM and 8CPU). After this If I try to invite someone using email, I see a log saying the email is queued but not sent.

Screenshot 2024-05-10 at 4 39 16 PM

this is our mail server configuration in config.yml:

mail.host: 'smtp.sendgrid.net'
mail.port: 587
mail.username: 'sendgrid-username'
mail.password: 'sendgrid-password'
mail.use-tls: true
mail.backend: 'smtp'
mail.use-ssl: false
mail.from: '[email protected]'
mail.list-namespace: 'bot.space'

Expected Result

An invite email should go through.

Actual Result

Invite email is not being sent

Event ID

No response

rohitdhas avatar May 10 '24 11:05 rohitdhas

The mail would be queued from the web container, but it's actually sent from the worker container. Unless, you're executing it from the "send test email" button, then it's not queued and it's directly sent from the web container.

Your configuration looks right, have you check on the Sendgrid configuration itself that it's allowing the SMTP sending from some specific IP address or specific from sender?

aldy505 avatar May 11 '24 02:05 aldy505

just checked sentry-self-hosted-worker-1 container logs and I found these errors:

14:02:58 [ERROR] celery.app.trace: Task sentry.tasks.email.send_email[378f2c44-c2dc-4139-99d9-c15a6d6735cb] raised unexpected: SMTPServerDisconnected('Connection unexpectedly closed') (data={'hostname': 'celery@6b73afd5201f', 'id': '378f2c44-c2dc-4139-99d9-c15a6d6735cb', 'name': 'sentry.tasks.email.send_email', 'exc': "SMTPServerDisconnected('Connection unexpectedly closed')", 'traceback': 'Traceback (most recent call last):
 File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 477, in trace_task 
 R = retval = fun(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/celery.py", line 306, in _inner
   reraise(*exc_info)
 File "/usr/local/lib/python3.10/site-packages/sentry_sdk/_compat.py", line 115, in reraise
 raise value
 File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/celery.py", line 301, in _inner
   return f(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/sentry/silo/base.py", line 145, in override
  return original_method(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/sentry/tasks/base.py", line 117, in _wrapped
  result = func(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/sentry/tasks/email.py", line 55, in send_email
    send_messages([message])
 File "/usr/local/lib/python3.10/site-packages/sentry/utils/email/send.py", line 17, in send_messages
    sent = connection.send_messages(messages)
 File "/usr/local/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
    new_conn_created = self.open()
 File "/usr/local/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 69, in open
    self.connection.login(self.username, self.password)
 File "/usr/local/lib/python3.10/smtplib.py", line 739, in login
    (code, resp) = self.auth(
 File "/usr/local/lib/python3.10/smtplib.py", line 642, in auth
    (code, resp) = self.docmd("AUTH", mechanism + " " + response)
 File "/usr/local/lib/python3.10/smtplib.py", line 432, in docmd
    return self.getreply()
 File "/usr/local/lib/python3.10/smtplib.py", line 405, in getreply 
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed', 'args': '()', 'kwargs': "{'message': <django.core.mail.message.EmailMultiAlternatives object at 0x7f5f9a62f8e0>, '__start_time': 1715349778.017939}", 'description': 'raised unexpected', 'internal': False})
  File "/usr/local/lib/python3.10/site-packages/sentry/tasks/email.py", line 55, in send_email
  File "/usr/local/lib/python3.10/site-packages/sentry/utils/email/send.py", line 17, in send_messages
  File "/usr/local/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
  File "/usr/local/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 69, in open
12:22:38 [ERROR] celery.app.trace: Task sentry.tasks.email.send_email[62a66b70-96b7-4b6c-ba01-dc5681b1e594] raised unexpected: SMTPServerDisconnected('Connection unexpectedly closed') (data={'hostname': 'celery@6b73afd5201f', 'id': '62a66b70-96b7-4b6c-ba01-dc5681b1e594', 'name': 'sentry.tasks.email.send_email', 'exc': "SMTPServerDisconnected('Connection unexpectedly closed')", 'traceback': 'Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/celery.py", line 306, in _inner
    reraise(*exc_info)
  File "/usr/local/lib/python3.10/site-packages/sentry_sdk/_compat.py", line 115, in reraise
    raise value
  File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/celery.py", line 301, in _inner
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/sentry/silo/base.py", line 145, in override
    return original_method(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/sentry/tasks/base.py", line 117, in _wrapped
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/sentry/tasks/email.py", line 55, in send_email
    send_messages([message])
  File "/usr/local/lib/python3.10/site-packages/sentry/utils/email/send.py", line 17, in send_messages
    sent = connection.send_messages(messages)
  File "/usr/local/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
    new_conn_created = self.open()
  File "/usr/local/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 69, in open
    self.connection.login(self.username, self.password)
  File "/usr/local/lib/python3.10/smtplib.py", line 739, in login
    (code, resp) = self.auth(
  File "/usr/local/lib/python3.10/smtplib.py", line 642, in auth
    (code, resp) = self.docmd("AUTH", mechanism + " " + response)
  File "/usr/local/lib/python3.10/smtplib.py", line 432, in docmd
    return self.getreply()
  File "/usr/local/lib/python3.10/smtplib.py", line 405, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed', 'args': '()', 'kwargs': "{'message': <django.core.mail.message.EmailMultiAlternatives object at 0x7f5f8b47d4e0>, '__start_time': 1715430158.554215}", 'description': 'raised unexpected', 'internal': False})

rohitdhas avatar May 11 '24 12:05 rohitdhas

As @aldy505 has mentioned above, have you checked the Sendgrid configuration itself?

hubertdeng123 avatar May 14 '24 20:05 hubertdeng123

Yes, my sendgrid config is looking fine. I also tried adding my server ip to sendgrid's allowed IP list, but no luck.

rohitdhas avatar May 16 '24 15:05 rohitdhas

Is your self-hosted instance TLS/SSL encrypted? Running out of ideas here...

hubertdeng123 avatar May 17 '24 16:05 hubertdeng123

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

getsantry[bot] avatar Jun 08 '24 07:06 getsantry[bot]