Error sending emails by Sentry service

Hi,

I configured Sentry to use our email server in order to send emails. The /etc/sentry/config.yml looks like this:

###############
# Mail Server #
###############

mail.backend: 'smtp'  # Use dummy if you want to disable email entirely
mail.host: 'mail.company.de'
mail.port: 25
mail.username: 'jenkins@company.de'
mail.password: 'password'
mail.use-tls: false
# The email address to send on behalf of
mail.from: 'sentry@company.de'

# If you'd like to configure email replies, enable this.
# mail.enable-replies: false

# When email-replies are enabled, this value is used in the Reply-To header
# mail.reply-hostname: ''

# If you're using mailgun for inbound mail, set your API key and configure a
# route to forward to /api/hooks/mailgun/inbound/
# mail.mailgun-api-key: ''

Unfortunately, the emails are not sent. I get this Sentry internal error:

Messagegaierror: [Errno -2] Name or service not known

Exception(most recent call first)gaierror: [Errno -2] Name or service not known
  File "celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
  File "sentry/tasks/base.py", line 54, in _wrapped
    result = func(*args, **kwargs)
  File "sentry/tasks/email.py", line 72, in send_email
    send_messages([message])
  File "sentry/utils/email.py", line 405, in send_messages
    sent = connection.send_messages(messages)
  File "django/core/mail/backends/smtp.py", line 87, in send_messages
    new_conn_created = self.open()
  File "django/core/mail/backends/smtp.py", line 48, in open
    local_hostname=DNS_NAME.get_fqdn())
  File "python2.7/smtplib.py", line 255, in __init__
    (code, msg) = self.connect(host, port)
  File "python2.7/smtplib.py", line 315, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "python2.7/smtplib.py", line 290, in _get_socket
    return socket.create_connection((host, port), timeout)
  File "python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):

I don’t know which “Name or service” Sentry it doesn’t know. I checked with telnet if it can comunicates with the mail server:

/usr/bin/telnet mail.company.de 25
Trying 10.15.31.1...
Connected to mail.company.de.
Escape character is '^]'.
220-trixter.de ESMTP Postfix
220 trixter.de ESMTP Postfix

And I think this internal Sentry error is related to the same issue:

MessageSMTPException: SMTP AUTH extension not supported by server.

Exception(most recent call first)SMTPException: SMTP AUTH extension not supported by server.
  File "celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
  File "sentry/tasks/base.py", line 54, in _wrapped
    result = func(*args, **kwargs)
  File "sentry/tasks/email.py", line 72, in send_email
    send_messages([message])
  File "sentry/utils/email.py", line 405, in send_messages
    sent = connection.send_messages(messages)
  File "django/core/mail/backends/smtp.py", line 87, in send_messages
    new_conn_created = self.open()
  File "django/core/mail/backends/smtp.py", line 54, in open
    self.connection.login(self.username, self.password)
  File "python2.7/smtplib.py", line 584, in login
    raise SMTPException("SMTP AUTH extension not supported by server.")

From Sentry server logs:

Dec 19 19:33:09 hostname sentry: raise SMTPException("SMTP AUTH extension not supported by server.")
Dec 19 19:33:09 hostname sentry: SMTPException: SMTP AUTH extension not supported by server.
Dec 19 19:33:09 hostname sentry: 18:33:09 [ERROR] celery.worker.job: Task sentry.tasks.email.send_email[a0faf01a-6dfa-4d4d-9cc0-4a8064824e0b] raised unexpected: SMTPException('SMTP AUTH extension not supported by server.',) (data={u'hostname': 'celery@hostname.company.intern', u'name': 'sentry.tasks.email.send_email', u'args': '[]', u'internal': False, u'kwargs': "{'message': <django.core.mail.message.EmailMultiAlternatives object at 0x4b08190>}", u'id': 'a0faf01a-6dfa-4d4d-9cc0-4a8064824e0b'})

Any ideas what it can be configured wrong? I am missing any package?

This sounds like a problem with your SMTP server not supporting SMTP AUTH. I’m not very familiar with running mail servers, so I’m not sure what you need to do here. This doesn’t seem like anything wrong with Sentry itself, rather a problem with your setup.

1 Like

I see. Does Sentry has an internal email server which I can use it to send emails?

No. It can only communicate to an external SMTP server.

Ok. I use this configuration in order to send emails which works for me:

###############
# Mail Server #
###############

mail.backend: 'django.core.mail.backends.smtp.EmailBackend'  # Use dummy if you want to disable email entirely
mail.host: 'localhost'
mail.port: 25
mail.username: ''
mail.password: ''
mail.use-tls: false
# The email address to send on behalf of
mail.from: 'sentry@company.de'