所以我在做smtp套接字程序。我用的是gmail smtp。我面临的身份验证问题,因为我的代码挂起后,服务器要求我的用户名。下面是我的身份验证码
auth = 'AUTH LOGIN\r\n'
clientSocketSSL.send(auth.encode())
recv1 = clientSocketSSL.recv(1024).decode()
print(recv1)
if recv1[:3] != '334':
print('334 reply not received from server')
username = base64.b64encode(b'******@gmail.com\r\n')
clientSocketSSL.send(username)
recv1 = clientSocketSSL.recv(1024).decode()
print(recv1)
if recv1[:3] != '334':
print('334 reply not received from server')
password = base64.b64encode(b'*******\r\n')
clientSocketSSL.send(password)
recv1 = clientSocketSSL.recv(1024).decode()
print(recv1)
if recv1[:3] != '235':
print('235 reply not received from server')
您不应该在用base64编码的字符串中包含
\r\n
。它需要在base64编码的用户名或密码之后发送相关问题 更多 >
编程相关推荐