Skip to content

Commit

Permalink
Merge 6f91633 into 797bebe
Browse files Browse the repository at this point in the history
  • Loading branch information
theo-o committed Aug 1, 2019
2 parents 797bebe + 6f91633 commit f9f6302
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion intranet/apps/notifications/emails.py
Expand Up @@ -31,6 +31,11 @@ def email_send(text_template, html_template, data, subject, emails, headers=None
msg = EmailMultiAlternatives(subject, text_content, settings.EMAIL_FROM, emails, headers=headers)
msg.attach_alternative(html_content, "text/html")
logger.debug("Emailing %s to %s", subject, emails)
msg.send()

# We only want to actually send emails if we are in production or explicitly force sending.
if settings.PRODUCTION or settings.FORCE_EMAIL_SEND:
msg.send()
else:
logger.debug("Refusing to email in non-production environments. To force email sending, enable settings.FORCE_EMAIL_SEND.")

return msg
3 changes: 3 additions & 0 deletions intranet/settings/__init__.py
Expand Up @@ -74,6 +74,9 @@
EMAIL_ANNOUNCEMENTS = PRODUCTION
SEND_ANNOUNCEMENT_APPROVAL = PRODUCTION

# Whether to force sending emails, even if we aren't in production.
FORCE_EMAIL_SEND = False

# Don't require https for testing.
SESSION_COOKIE_SECURE = PRODUCTION
CSRF_COOKIE_SECURE = PRODUCTION
Expand Down

0 comments on commit f9f6302

Please sign in to comment.