Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Undelete the login() call inadvertantly removed in 4e0a2fe

Refs #21271.
  • Loading branch information...
commit 3afde36d03e2b3b5ff5a265af39d8fb27afa8959 1 parent 43cfc65
Claude Paroz claudep authored
Showing with 12 additions and 0 deletions.
  1. +2 −0  django/core/mail/backends/smtp.py
  2. +10 −0 tests/mail/tests.py
2  django/core/mail/backends/smtp.py
View
@@ -56,6 +56,8 @@ def open(self):
self.connection.ehlo()
self.connection.starttls()
self.connection.ehlo()
+ if self.username and self.password:
+ self.connection.login(self.username, self.password)
except smtplib.SMTPException:
if not self.fail_silently:
raise
10 tests/mail/tests.py
View
@@ -880,6 +880,16 @@ def test_email_disabled_authentication(self):
self.assertEqual(backend.username, '')
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):
"""
Test that closing the backend while the SMTP server is stopped doesn't
Please sign in to comment.
Something went wrong with that request. Please try again.