From 0aca07271a6e5bcc0308aa6724d1f12790ed8d1b Mon Sep 17 00:00:00 2001
From: Sebastian Noack <sebastian.noack@gmail.com>
Date: Tue, 16 Oct 2012 17:34:36 +0200
Subject: [PATCH] Handle SMTPServerDisconnected in EmailBackend.close().
---
django/core/mail/backends/smtp.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/django/core/mail/backends/smtp.py b/django/core/mail/backends/smtp.py
index 3ee283b..5d4bfa5 100644
a
|
b
|
class EmailBackend(BaseEmailBackend):
|
62 | 62 | try: |
63 | 63 | try: |
64 | 64 | self.connection.quit() |
65 | | except socket.sslerror: |
| 65 | except (socket.sslerror, smtplib.SMTPServerDisconnected): |
66 | 66 | # This happens when calling quit() on a TLS connection |
67 | | # sometimes. |
| 67 | # sometimes, or when the connection was already disconnected |
| 68 | # by the server. |
68 | 69 | self.connection.close() |
69 | 70 | except: |
70 | 71 | if self.fail_silently: |