diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-01-12 23:33:48 +0000 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-01-12 23:38:28 +0000 |
| commit | 9d2c5b0420bcbf00505a403241a2927cabc90805 (patch) | |
| tree | 16cb160cbc6d5e65087a8a20da1eefc1b5bdcad6 | |
| parent | 89f12c0596db201c7d052120d4337a36bc0aab17 (diff) | |
Undelete the `return True` removed in 4e0a2fe.
This is quite important otherwise we don't close our connections to the
SMTP server.
| -rw-r--r-- | django/core/mail/backends/smtp.py | 1 | ||||
| -rw-r--r-- | tests/mail/tests.py | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/django/core/mail/backends/smtp.py b/django/core/mail/backends/smtp.py index e72e372ca9..dc6afb0a81 100644 --- a/django/core/mail/backends/smtp.py +++ b/django/core/mail/backends/smtp.py @@ -57,6 +57,7 @@ class EmailBackend(BaseEmailBackend): self.connection.ehlo() if self.username and self.password: self.connection.login(self.username, self.password) + return True except smtplib.SMTPException: if not self.fail_silently: raise diff --git a/tests/mail/tests.py b/tests/mail/tests.py index ebb8ec5448..6a0172467c 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -894,6 +894,16 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase): self.assertRaisesMessage(SMTPException, 'SMTP AUTH extension not supported by server.', backend.open) + def test_server_open(self): + """ + Test that open() tells us whether it opened a connection. + """ + backend = smtp.EmailBackend(username='', password='') + self.assertFalse(backend.connection) + opened = backend.open() + backend.close() + self.assertTrue(opened) + def test_server_stopped(self): """ Test that closing the backend while the SMTP server is stopped doesn't |
