Skip to content

Commit

Permalink
Add logging where email building can result in null or empty result set.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaemming committed Jan 19, 2016
1 parent 333c457 commit ed7c3ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/sentry/plugins/sentry_mail/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def _build_message(self, subject, template=None, html_template=None, body=None,
project=None, group=None, headers=None, context=None):
send_to = self.get_send_to(project)
if not send_to:
logger.debug('Skipping message rendering, no users to send to.')
return

subject_prefix = self.get_option('subject_prefix', project) or self.subject_prefix
Expand Down
9 changes: 8 additions & 1 deletion src/sentry/utils/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
from __future__ import absolute_import

import logging
import os
import time
import toronado
Expand All @@ -25,6 +26,9 @@
from sentry.utils import metrics
from sentry.utils.safe import safe_execute


logger = logging.getLogger(__name__)

SMTP_HOSTNAME = getattr(settings, 'SENTRY_SMTP_HOSTNAME', 'localhost')
ENABLE_EMAIL_REPLIES = getattr(settings, 'SENTRY_ENABLE_EMAIL_REPLIES', False)

Expand Down Expand Up @@ -240,7 +244,10 @@ def build(self, to, reply_to=None, cc=None, bcc=None):
def get_built_messages(self, to=None, bcc=None):
send_to = set(to or ())
send_to.update(self._send_to)
return [self.build(to=email, reply_to=send_to, bcc=bcc) for email in send_to]
results = [self.build(to=email, reply_to=send_to, bcc=bcc) for email in send_to]
if not results:
logger.debug('Did not build any messages, no users to send to.')
return results

def send(self, to=None, bcc=None, fail_silently=False):
messages = self.get_built_messages(to, bcc=bcc)
Expand Down

0 comments on commit ed7c3ef

Please sign in to comment.