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

Not able to send invite emails #3037

Open
rohitdhas opened this issue May 10, 2024 · 5 comments
Open

Not able to send invite emails #3037

rohitdhas opened this issue May 10, 2024 · 5 comments

Comments

@rohitdhas
Copy link

rohitdhas commented May 10, 2024

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

@aldy505
Copy link
Collaborator

aldy505 commented May 11, 2024

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?

@rohitdhas
Copy link
Author

rohitdhas commented May 11, 2024

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})

@hubertdeng123
Copy link
Member

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

@rohitdhas
Copy link
Author

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

@hubertdeng123
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Status: No status
Development

No branches or pull requests

3 participants