Skip to content

Commit 33909a1

Browse files
committed
Skip email sending if there are no recipients
1 parent 9bca393 commit 33909a1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

redash/destinations/email.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ def icon(cls):
2424
return 'fa-envelope'
2525

2626
def notify(self, alert, query, user, new_state, app, host, options):
27-
recipients = [email for email in options.get('addresses').split(',') if email]
27+
recipients = [email for email in options.get('addresses', '').split(',') if email]
28+
29+
if not recipients:
30+
logging.warning("No emails given. Skipping send.")
31+
2832
html = """
2933
Check <a href="{host}/alerts/{alert_id}">alert</a> / check <a href="{host}/queries/{query_id}">query</a>.
3034
""".format(host=host, alert_id=alert.id, query_id=query.id)
@@ -39,6 +43,6 @@ def notify(self, alert, query, user, new_state, app, host, options):
3943
)
4044
mail.send(message)
4145
except Exception:
42-
logging.exception("mail send ERROR.")
46+
logging.exception("Mail send error.")
4347

4448
register(Email)

0 commit comments

Comments
 (0)