1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.5.x] Fixed #19134 -- Allowed closing smtp backend when the server is stopped

Thanks Sebastian Noack for the report and the initial patch.
Backport of 1b3f832ab7 from master.
This commit is contained in:
Claude Paroz
2013-01-03 18:49:00 +01:00
parent a893ee3315
commit 4081042ef5
2 changed files with 19 additions and 5 deletions

View File

@@ -63,9 +63,10 @@ class EmailBackend(BaseEmailBackend):
try:
try:
self.connection.quit()
except socket.sslerror:
except (socket.sslerror, smtplib.SMTPServerDisconnected):
# This happens when calling quit() on a TLS connection
# sometimes.
# sometimes, or when the connection was already disconnected
# by the server.
self.connection.close()
except:
if self.fail_silently: