Loading django/core/mail/backends/smtp.py +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ class EmailBackend(BaseEmailBackend): 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 Loading tests/mail/tests.py +10 −0 Original line number Diff line number Diff line Loading @@ -880,6 +880,16 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase): 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 Loading Loading
django/core/mail/backends/smtp.py +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ class EmailBackend(BaseEmailBackend): 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 Loading
tests/mail/tests.py +10 −0 Original line number Diff line number Diff line Loading @@ -880,6 +880,16 @@ class SMTPBackendTests(BaseEmailBackendTests, SimpleTestCase): 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 Loading