Commit 98f01ebc by Awais Jibran

Add logging to better monitor and determine root cause for email sending failures.

parent 5d439669
...@@ -545,6 +545,7 @@ class Registration(models.Model): ...@@ -545,6 +545,7 @@ class Registration(models.Model):
self.user.is_active = True self.user.is_active = True
self._track_activation() self._track_activation()
self.user.save() self.user.save()
log.info(u'User %s (%s) account is successfully activated.', self.user.username, self.user.email)
def _track_activation(self): def _track_activation(self):
""" Update the isActive flag in mailchimp for activated users.""" """ Update the isActive flag in mailchimp for activated users."""
......
...@@ -2274,16 +2274,15 @@ def reactivation_email_for_user(user): ...@@ -2274,16 +2274,15 @@ def reactivation_email_for_user(user):
subject = render_to_string('emails/activation_email_subject.txt', context) subject = render_to_string('emails/activation_email_subject.txt', context)
subject = ''.join(subject.splitlines()) subject = ''.join(subject.splitlines())
message = render_to_string('emails/activation_email.txt', context) message = render_to_string('emails/activation_email.txt', context)
from_address = configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
try: try:
user.email_user(subject, message, configuration_helpers.get_value( user.email_user(subject, message, from_address)
'email_from_address',
settings.DEFAULT_FROM_EMAIL,
))
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
log.error( log.error(
u'Unable to send reactivation email from "%s"', u'Unable to send reactivation email from "%s" to "%s"',
configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL), from_address,
user.email,
exc_info=True exc_info=True
) )
return JsonResponse({ return JsonResponse({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment