From f6ef035dfb37c614a27384602ca4f9dabc34a2fc Mon Sep 17 00:00:00 2001 From: Mathijs de Bruin Date: Thu, 3 Oct 2013 18:25:12 +0200 Subject: [PATCH] Catch general socket errors for mail submission. An addition to 57620b658988aac6970bf0fa2467ef742b95bcb1 to get tests to run with no connection to the outside world. Also see #92. --- newsletter/views.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/newsletter/views.py b/newsletter/views.py index 53326bed..5910c865 100644 --- a/newsletter/views.py +++ b/newsletter/views.py @@ -2,10 +2,9 @@ logger = logging.getLogger(__name__) - import datetime +import socket -from socket import gaierror from smtplib import SMTPException from django.core.exceptions import ValidationError, ImproperlyConfigured @@ -415,7 +414,7 @@ def form_valid(self, form): try: self.subscription.send_activation_email(action=self.action) - except (SMTPException, gaierror), e: + except (SMTPException, socket.error), e: logger.exception( 'Error %s while submitting email to %s.', e, self.subscription.email