From 200394f60860a4d2d8b3b893f0a22ba45b167b95 Mon Sep 17 00:00:00 2001 From: Waheed Ahmed Date: Wed, 4 Jun 2014 16:05:24 +0500 Subject: [PATCH] Added logging for sender email address on BotoServerError. LMS-2734 --- common/djangoapps/student/views.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 2d7e33c8c3..f409c884f7 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -1260,7 +1260,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many else: user.email_user(subject, message, from_address) except Exception: # pylint: disable=broad-except - log.warning('Unable to send activation email to user', exc_info=True) + log.error('Unable to send activation email to user from "{from_address}"'.format(from_address=from_address), exc_info=True) js['value'] = _('Could not send activation e-mail.') # What is the correct status code to use here? I think it's 500, because # the problem is on the server's end -- but also, the account was created. @@ -1584,7 +1584,7 @@ def reactivation_email_for_user(user): try: user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL) except Exception: # pylint: disable=broad-except - log.warning('Unable to send reactivation email', exc_info=True) + log.error('Unable to send reactivation email from "{from_address}"'.format(from_address=settings.DEFAULT_FROM_EMAIL), exc_info=True) return JsonResponse({ "success": False, "error": _('Unable to send reactivation email') @@ -1658,8 +1658,14 @@ def change_email_request(request): 'email_from_address', settings.DEFAULT_FROM_EMAIL ) - - send_mail(subject, message, from_address, [pec.new_email]) + try: + send_mail(subject, message, from_address, [pec.new_email]) + except Exception: # pylint: disable=broad-except + log.error('Unable to send email activation link to user from "{from_address}"'.format(from_address=from_address), exc_info=True) + return JsonResponse({ + "success": False, + "error": _('Unable to send email activation link. Please try again later.') + }) return JsonResponse({"success": True})