1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #26210 -- Prevented SMTP backend from trying to send mail after a connection failure.

This commit is contained in:
levental
2016-09-20 19:34:01 +02:00
committed by Tim Graham
parent 2b8ccff3b6
commit 42dc9d0400
2 changed files with 17 additions and 3 deletions

View File

@@ -1448,6 +1448,19 @@ class SMTPBackendTests(BaseEmailBackendTests, SMTPBackendTestsBase):
finally:
SMTP.send = send
def test_send_messages_after_open_failed(self):
"""
send_messages() shouldn't try to send messages if open() raises an
exception after initializing the connection.
"""
backend = smtp.EmailBackend()
# Simulate connection initialization success and a subsequent
# connection exception.
backend.connection = True
backend.open = lambda: None
email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'])
self.assertEqual(backend.send_messages([email]), None)
class SMTPBackendStoppedServerTest(SMTPBackendTestsBase):
"""