0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

Undelete the login() call inadvertantly removed in 4e0a2fe59c

Refs #21271.
This commit is contained in:
Claude Paroz 2013-10-25 11:19:41 +02:00
parent 43cfc652d2
commit 3afde36d03
2 changed files with 12 additions and 0 deletions

View File

@ -56,6 +56,8 @@ class EmailBackend(BaseEmailBackend):
self.connection.ehlo() self.connection.ehlo()
self.connection.starttls() self.connection.starttls()
self.connection.ehlo() self.connection.ehlo()
if self.username and self.password:
self.connection.login(self.username, self.password)
except smtplib.SMTPException: except smtplib.SMTPException:
if not self.fail_silently: if not self.fail_silently:
raise raise

View File

@ -880,6 +880,16 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase):
self.assertEqual(backend.username, '') self.assertEqual(backend.username, '')
self.assertEqual(backend.password, '') self.assertEqual(backend.password, '')
def test_auth_attempted(self):
"""
Test that opening the backend with non empty username/password tries
to authenticate against the SMTP server.
"""
backend = smtp.EmailBackend(
username='not empty username', password='not empty password')
self.assertRaisesMessage(SMTPException,
'SMTP AUTH extension not supported by server.', backend.open)
def test_server_stopped(self): def test_server_stopped(self):
""" """
Test that closing the backend while the SMTP server is stopped doesn't Test that closing the backend while the SMTP server is stopped doesn't