email backend should pass passwrord as string, not as unicode to smtplib
to avoid this error
--
Ticket URL: <https://code.djangoproject.com/ticket/27131>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
I have no way to reproduce this -- can you submit a patch with a test?
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:1>
Comment (by claudep):
Would it be possible to test with Python 3?
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:2>
Comment (by claudep):
FYI, I'm currently working on a test for this in the Django test suite.
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:3>
Comment (by slavugan):
I have checked for python3 everything is ok, because of with python3
Django passes password as string to smtplib, so this error is relevant
only for python2.
For fix in __init__ in django/core/mail/backends/smtp.py we should add
something like this:
{{{
if self.password.__class__.__name__ == 'unicode':
try:
self.password = str(self.password)
except UnicodeEncodeError:
pass
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:4>
* has_patch: 0 => 1
* version: 1.8 => master
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
[https://github.com/django/django/pull/7178 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:6>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"fe252c0a5a2ceb5c97aafc16a42dbe5ad03ef1e9" fe252c0a]:
{{{
#!CommitTicketReference repository=""
revision="fe252c0a5a2ceb5c97aafc16a42dbe5ad03ef1e9"
Fixed #27131 -- Passed proper string type to SMTP connection login
Passing an Unicode string on Python 2 was crashing the connection.
Thanks slav...@gmail.com for the report, and Tim Graham for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:7>
Comment (by claudep):
As suggested by Tim on the pull request, a workaround on older Django
could be to define email username and pasword as bytestrings.
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:8>
Comment (by GitHub <noreply@…>):
In [changeset:"cdad96e6330cd31185f7496aaf8eb316f2773d6d" cdad96e6]:
{{{
#!CommitTicketReference repository=""
revision="cdad96e6330cd31185f7496aaf8eb316f2773d6d"
Refs #27131 -- Removed SMTPBackendTests.test_server_login().
test_server_login() was a regression test for a crash when passing
Unicode strings to SMTP server using CRAM-MD5 method on Python 2.
Python 2 is no longer supported and test_server_login() passes even
without FakeSMTPChannel.smtp_AUTH() because
smtplib.SMTPAuthenticationError is raised when AUTH is not implemented.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"8ab95364b5182fd702478289f98b01d16a21016e" 8ab9536]:
{{{
#!CommitTicketReference repository=""
revision="8ab95364b5182fd702478289f98b01d16a21016e"
[4.0.x] Refs #27131 -- Removed SMTPBackendTests.test_server_login().
test_server_login() was a regression test for a crash when passing
Unicode strings to SMTP server using CRAM-MD5 method on Python 2.
Python 2 is no longer supported and test_server_login() passes even
without FakeSMTPChannel.smtp_AUTH() because
smtplib.SMTPAuthenticationError is raised when AUTH is not implemented.
Backport of cdad96e6330cd31185f7496aaf8eb316f2773d6d from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:10>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"137a9899d7965432fc24cf6fc0331e333316a1dd" 137a9899]:
{{{
#!CommitTicketReference repository=""
revision="137a9899d7965432fc24cf6fc0331e333316a1dd"
[3.2.x] Refs #27131 -- Removed SMTPBackendTests.test_server_login().
test_server_login() was a regression test for a crash when passing
Unicode strings to SMTP server using CRAM-MD5 method on Python 2.
Python 2 is no longer supported and test_server_login() passes even
without FakeSMTPChannel.smtp_AUTH() because
smtplib.SMTPAuthenticationError is raised when AUTH is not implemented.
Backport of cdad96e6330cd31185f7496aaf8eb316f2773d6d from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27131#comment:11>