This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author merkel
Recipients barry, merkel, r.david.murray
Date 2015-10-20.21:16:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1445375804.68.0.808666638714.issue25446@psf.upfronthosting.co.za>
In-reply-to
Content
Let us assume you want to establish a smtp session with AUTH LOGIN as the supported authentication type. Sample code to send mail: Typical preparation steps like

    with SMTP( mailserver, 587 ) as smtp:
      # smtp.set_debuglevel(1)
      smtp.ehlo()
      smtp.starttls()
      smtp.ehlo()
      smtp.login( account, password )

If you try to login (last line in sample code above) at the smtp server then the smtp server will expect a command to be send like

AUTH LOGIN <base64encodedaccountdata>

Now switching from sample code to our smtplib.py:

Since the "AUTH LOGIN" is missing in original Python35/Lib/smtplib.py in line...

660c663
<         (code, resp) = self.docmd(
---
>         (code, resp) = self.docmd("AUTH", "LOGIN " +

... the smtp server will answer that the library is sending an unknown command here. That is why I added... "AUTH", "LOGIN " + ...at this line.

Line 660 in class SMTP: def auth_login is called before it reaches line 630 in class SMTP: def auth

In case of authentication type AUTH LOGIN in line 630 you must not call with "AUTH", mechanism + " " +

So the following changes have to be applied at least for AUTH LOGIN mechanism

630c630,633
<             (code, resp) = self.docmd("AUTH", mechanism + " " + response)
---
>             if mechanism == 'LOGIN':
>                 (code, resp) = self.docmd(response)
>             else:
>                 (code, resp) = self.docmd("AUTH", mechanism + " " + response)

The first change affecting line 660 described above will will imply that the you remove the AUTH mechanism in line 630. For mechanism LOGIN the base64 encoded password will be needed to be sent in 660...

See possible fix in the diff above.

To ease understanding the fix I will apply a running version of my local Lib/smtplib.py (instead of just providing the diff lines). Feel free to directly use the file.
History
Date User Action Args
2015-10-20 21:16:46merkelsetrecipients: + merkel, barry, r.david.murray
2015-10-20 21:16:44merkelsetmessageid: <1445375804.68.0.808666638714.issue25446@psf.upfronthosting.co.za>
2015-10-20 21:16:44merkellinkissue25446 messages
2015-10-20 21:16:44merkelcreate