Ticket #19134: 0001-Handle-SMTPServerDisconnected-in-EmailBackend.close.patch

File 0001-Handle-SMTPServerDisconnected-in-EmailBackend.close.patch, 1.1 KB (added by Sebastian Noack, 12 years ago)
  • django/core/mail/backends/smtp.py

    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):  
    6262        try:
    6363            try:
    6464                self.connection.quit()
    65             except socket.sslerror:
     65            except (socket.sslerror, smtplib.SMTPServerDisconnected):
    6666                # This happens when calling quit() on a TLS connection
    67                 # sometimes.
     67                # sometimes, or when the connection was already disconnected
     68                # by the server.
    6869                self.connection.close()
    6970            except:
    7071                if self.fail_silently:
Back to Top