我收到这样的消息:530-5.7.0需要身份验证.在python上使用套接字模块进行套接字编程时



我正在使用python中的套接字模块ssl模块令MAIL from时,都会显示消息:530-5.7.0 Authentication Required。我正在寻找一个不使用smtplib模块的解决方案。

这是代码:

from socket import *
import ssl

menssagem = 'rn Eu gosto de redes'
finMenssagem = 'rn.rn'
mailServer =  'smtp.gmail.com'
mailPort = 465
context = ssl.create_default_context()
with create_connection((mailServer, mailPort)) as sock:
with context.wrap_socket(sock, server_hostname=mailServer) as clientSocket:
print(clientSocket.version())
recv = clientSocket.recv(1024).decode()
print(recv)
if recv[:3] != '220':
print('220 reply not received from server.')
heloCommand = 'HELO Alicern'
clientSocket.send(heloCommand.encode())
recv1 = clientSocket.recv().decode()
print(recv1)   
if recv1[:3] != '250':
print('250 reply not received from server.')
mailfromCommand = 'MAIL FROM: <arthursilvamatias@gmail.com>rn'      
clientSocket.send(mailfromCommand.encode())
recv2 = clientSocket.recv().decode()
print(recv2)

运行代码的图像:我的代码

您正试图使用Gmail的服务发送出站电子邮件。

他们试图通过防止未经授权的用户伪装成你来发送电子邮件来保护你的帐户。

此链接应说明您需要执行哪些操作才能进行身份验证:https://stackabuse.com/how-to-send-emails-with-gmail-using-python/#:%7E:text=As%20for%20the%20actual%20Python,com%27%2C%20465(%20服务器。

最新更新