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.

classification
Title: smtplib on linux fails to log in correctly
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: murphdasurf
Priority: normal Keywords:

Created on 2017-08-29 12:56 by murphdasurf, last changed 2022-04-11 14:58 by admin.

Messages (2)
msg300986 - (view) Author: (murphdasurf) Date: 2017-08-29 12:56
The protocol should run like this:

send: 'ehlo XXXXXXXXXXXXX\r\n'
reply: b'250-XXXXXXXXXXXXXXXXXX.com\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-SIZE 100480000\r\n'
reply: b'250-VRFY\r\n'
reply: b'250-ETRN\r\n'
reply: b'250-STARTTLS\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250 DSN\r\n'
reply: retcode (250); Msg: b'XXXXXXXXXXXXXXXX.com\nPIPELINING\nSIZE 100480000\nVRFY\nETRN\nSTARTTLS\nENHANCEDSTATUSCODES\n8BITMIME\nDSN'
send: 'STARTTLS\r\n'
reply: b'220 2.0.0 Ready to start TLS\r\n'
reply: retcode (220); Msg: b'2.0.0 Ready to start TLS'
send: 'ehlo XXXXXXXXXXXXXXXXXXXXX\r\n'
reply: b'250-XXXXXXXXXXXXXXXXXX.com\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-SIZE 100480000\r\n'
reply: b'250-VRFY\r\n'
reply: b'250-ETRN\r\n'
reply: b'250-AUTH LOGIN\r\n'
reply: b'250-AUTH=LOGIN\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250 DSN\r\n'
reply: retcode (250); Msg: b'XXXXXXXXXXXXXXXXXXXXXX.com\nPIPELINING\nSIZE 100480000\nVRFY\nETRN\nAUTH LOGIN\nAUTH=LOGIN\nENHANCEDSTATUSCODES\n8BITMIME\nDSN'
send: 'AUTH LOGIN XXXXXXXXXXXXXXX\r\n'
reply: b'334 RRRRRRRRRRR\r\n'
reply: retcode (334); Msg: b'RRRRRRRRR'
send: 'TTTTTTTTTTTT=\r\n'
reply: b'235 2.7.0 Authentication successful\r\n'
reply: retcode (235); Msg: b'2.7.0 Authentication successful'


And in fact it does so on Windows. However, on Linux it runs like this:

send: 'ehlo XXXXXXXXXXXXX\r\n'
reply: b'250-XXXXXXXXXXXXX.com\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-SIZE 100480000\r\n'
reply: b'250-VRFY\r\n'
reply: b'250-ETRN\r\n'
reply: b'250-STARTTLS\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250 DSN\r\n'
reply: retcode (250); Msg: b'XXXXXXXXXXXXX.com\nPIPELINING\nSIZE 100480000\nVRFY\nETRN\nSTARTTLS\nENHANCEDSTATUSCODES\n8BITMIME\nDSN'
send: 'STARTTLS\r\n'
reply: b'220 2.0.0 Ready to start TLS\r\n'
reply: retcode (220); Msg: b'2.0.0 Ready to start TLS'
send: 'ehlo XXXXXXXXXXXXX\r\n'
reply: b'250-XXXXXXXXXXXXX.com\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-SIZE 100480000\r\n'
reply: b'250-VRFY\r\n'
reply: b'250-ETRN\r\n'
reply: b'250-AUTH LOGIN\r\n'
reply: b'250-AUTH=LOGIN\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250 DSN\r\n'
reply: retcode (250); Msg: b'XXXXXXXXXXXXX.com\nPIPELINING\nSIZE 100480000\nVRFY\nETRN\nAUTH LOGIN\nAUTH=LOGIN\nENHANCEDSTATUSCODES\n8BITMIME\nDSN'
send: 'AUTH LOGIN XXXXXXXXXXXXXXX\r\n'
reply: b'334 RRRRRRRRRRR\r\n'
reply: retcode (334); Msg: b'RRRRRRRRRRR'
send: "b''\r\n"
reply: b'535 5.7.8 Error: authentication failed: another step is needed in authentication\r\n'
reply: retcode (535); Msg: b'5.7.8 Error: authentication failed: another step is needed in authentication'

The last sent message is an empty string and then the authentication fails. All other tokens which are replaced by XXXXXX, RRRRR or TTTTT are exactly the same.

This way the login fails and I can not use smtplib to send my mail.
msg300987 - (view) Author: (murphdasurf) Date: 2017-08-29 13:18
PS: The corresponding code is:

server_ssl = smtplib.SMTP(SERVER, PORT)
server_ssl.set_debuglevel(True)
server_ssl.ehlo()
server_ssl.starttls()
server_ssl.login(USER_FOR_AUTHENTICATION, XXXXXX)
History
Date User Action Args
2022-04-11 14:58:51adminsetgithub: 75483
2017-08-29 13:18:18murphdasurfsetmessages: + msg300987
2017-08-29 12:56:45murphdasurfcreate