所以我正在研究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')
答案 0 :(得分:0)
您不应在以base 64编码的字符串中包含\r\n
。它必须在以base64编码的用户名或密码之后发送。
username = base64.b64encode(b'******@gmail.com\r\n')
clientSocketSSL.send((username + '\r\n'));