Add error handling to send_mail
This commit is contained in:
+12
-9
@@ -23,16 +23,19 @@ from django.core.mail import send_mail
|
||||
|
||||
|
||||
def send_email(to, subject, body):
|
||||
success = send_mail(
|
||||
subject,
|
||||
body,
|
||||
settings.DEFAULT_EMAIL_FROM,
|
||||
[to],
|
||||
fail_silently=False,
|
||||
)
|
||||
try:
|
||||
success = send_mail(
|
||||
subject,
|
||||
body,
|
||||
settings.DEFAULT_EMAIL_FROM,
|
||||
[to],
|
||||
fail_silently=False,
|
||||
)
|
||||
if success == 0:
|
||||
raise Exception('Failed to send email!')
|
||||
|
||||
if success == 0:
|
||||
raise Exception('Failed to send email!')
|
||||
except Exception as ex:
|
||||
logging.exception('Failed to send email.')
|
||||
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
|
||||
Reference in New Issue
Block a user