From c0ae68490c48cce3f35e5c730b2d10ee0b852f64 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Sun, 19 Apr 2020 21:13:31 +0200 Subject: [PATCH] Also catch ConnectionError when sending mails --- cotisations/utils.py | 2 +- re2o/mail_utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cotisations/utils.py b/cotisations/utils.py index c370fe59..5da8eee0 100644 --- a/cotisations/utils.py +++ b/cotisations/utils.py @@ -50,7 +50,7 @@ def send_mail(mail, request): """Wrapper for Django's EmailMessage.send which handles errors""" try: mail.send() - except SMTPException as e: + except (SMTPException, ConnectionError) as e: if request: messages.error( request, diff --git a/re2o/mail_utils.py b/re2o/mail_utils.py index 065a9506..86d446fb 100644 --- a/re2o/mail_utils.py +++ b/re2o/mail_utils.py @@ -36,7 +36,7 @@ def send_mail(request, *args, **kwargs): try: kwargs["fail_silently"] = request is None django_send_mail(*args, **kwargs) - except SMTPException as e: + except (SMTPException, ConnectionError) as e: messages.error( request, _("Failed to send email: %(error)s.") % {