-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying To Concatenate Bytes and String in SMTPLIB #87291
Comments
The space is string, and either mechanism and/or response are bytes. import smtplib, ssl
port = 587
smtp_server = "---------------"
smtpserver = smtplib.SMTP(smtp_server, port)
smtpserver.set_debuglevel(2)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login("", "") 12:40:37.614737 send: 'ehlo [10.60.69.196]\r\n'
12:40:37.665528 reply: b'250-MWHPR20CA0007.outlook.office365.com Hello [65.54.12.68]\r\n'
12:40:37.665666 reply: b'250-SIZE 157286400\r\n'
12:40:37.665761 reply: b'250-PIPELINING\r\n'
12:40:37.665788 reply: b'250-DSN\r\n'
12:40:37.665806 reply: b'250-ENHANCEDSTATUSCODES\r\n'
12:40:37.665825 reply: b'250-STARTTLS\r\n'
12:40:37.665842 reply: b'250-8BITMIME\r\n'
12:40:37.665859 reply: b'250-BINARYMIME\r\n'
12:40:37.665876 reply: b'250-CHUNKING\r\n'
12:40:37.665893 reply: b'250 SMTPUTF8\r\n'
12:40:37.665919 reply: retcode (250); Msg: b'MWHPR20CA0007.outlook.office365.com Hello [65.54.12.68]\nSIZE 157286400\nPIPELINING\nDSN\nENHANCEDSTATUSCODES\nSTARTTLS\n8BITMIME\nBINARYMIME\nCHUNKING\nSMTPUTF8'
12:40:37.666440 send: 'STARTTLS\r\n'
12:40:37.716214 reply: b'220 2.0.0 SMTP server ready\r\n'
12:40:37.716265 reply: retcode (220); Msg: b'2.0.0 SMTP server ready'
12:40:37.878320 send: 'ehlo [10.60.69.196]\r\n'
12:40:37.928198 reply: b'250-MWHPR20CA0007.outlook.office365.com Hello [65.54.12.68]\r\n'
12:40:37.928259 reply: b'250-SIZE 157286400\r\n'
12:40:37.928285 reply: b'250-PIPELINING\r\n'
12:40:37.928304 reply: b'250-DSN\r\n'
12:40:37.928323 reply: b'250-ENHANCEDSTATUSCODES\r\n'
12:40:37.928437 reply: b'250-AUTH LOGIN XOAUTH2\r\n'
12:40:37.928461 reply: b'250-8BITMIME\r\n'
12:40:37.928494 reply: b'250-BINARYMIME\r\n'
12:40:37.928511 reply: b'250-CHUNKING\r\n'
12:40:37.928528 reply: b'250 SMTPUTF8\r\n'
12:40:37.928552 reply: retcode (250); Msg: b'MWHPR20CA0007.outlook.office365.com Hello [65.54.12.68]\nSIZE 157286400\nPIPELINING\nDSN\nENHANCEDSTATUSCODES\nAUTH LOGIN XOAUTH2\n8BITMIME\nBINARYMIME\nCHUNKING\nSMTPUTF8'
Traceback (most recent call last):
File "mail9.py", line 18, in <module>
smtpserver.login("", "")
File "/aae/msio_install_release1.9/scoring_engine.20201201.3.8.3/lib/python3.8/smtplib.py", line 723, in login
(code, resp) = self.auth(
File "/aae/msio_install_release1.9/scoring_engine.20201201.3.8.3/lib/python3.8/smtplib.py", line 635, in auth
(code, resp) = self.docmd("AUTH", mechanism + " " + response)
TypeError: can only concatenate str (not "bytes") to str |
I reproduced directly. by using a valid smtp server. |
problem seems to/could be in /usr/lib/python3.8/email/base64mime.py
If function is supposed to return str for any bytes input, then there it is returning the original bytes instance.. which is the trouble. it should return I would like to work/contribute on this issue.. I'll further investigate this issue and possible solution and comes with a patch rather sooner than later.. |
I filled the PR #24476 feel free to comment. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: