From 98f01ebc568a1cea1c771d3c0b328af109edb53d Mon Sep 17 00:00:00 2001 From: Awais Jibran Date: Fri, 2 Sep 2016 15:44:07 +0500 Subject: [PATCH] Add logging to better monitor and determine root cause for email sending failures. --- common/djangoapps/student/models.py | 1 + common/djangoapps/student/views.py | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 9aaf91a745..d4fc1f43c4 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -545,6 +545,7 @@ class Registration(models.Model): self.user.is_active = True self._track_activation() self.user.save() + log.info(u'User %s (%s) account is successfully activated.', self.user.username, self.user.email) def _track_activation(self): """ Update the isActive flag in mailchimp for activated users.""" diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index b9bb7ddfd7..6b3ffbf976 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -2274,16 +2274,15 @@ def reactivation_email_for_user(user): subject = render_to_string('emails/activation_email_subject.txt', context) subject = ''.join(subject.splitlines()) message = render_to_string('emails/activation_email.txt', context) + from_address = configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL) try: - user.email_user(subject, message, configuration_helpers.get_value( - 'email_from_address', - settings.DEFAULT_FROM_EMAIL, - )) + user.email_user(subject, message, from_address) except Exception: # pylint: disable=broad-except log.error( - u'Unable to send reactivation email from "%s"', - configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL), + u'Unable to send reactivation email from "%s" to "%s"', + from_address, + user.email, exc_info=True ) return JsonResponse({