无法通过python发送电子邮件-错误-smtplib,SMTPServer已断开连接:连接意外关闭

lymnna71  于 2023-02-17  发布在  Python
关注(0)|答案(1)|浏览(217)
port = 465  # For SSL
smtp_server = "smtp.mail.yahoo.com"
sender_email = "c.junction@yahoo.com"  # Enter your address
password = input("Type your password and press enter:")
receiver_email = "jawoneb660@jobsfeel.com"  # Enter receiver address
Subject = "Hi there"
message = """Hello World!!!
This message is sent from Python."""
context = ssl.create_default_context()

with smtplib.SMTP_SSL(smtp_server, port, context=context) as smtp:
     smtp.login(sender_email, password)
     smtp.sendmail(sender_email, receiver_email, Subject, message)

我试着检查是否有任何认证失败。电子邮件无法发送。我得到以下错误消息。
引发SMTPServer断开连接(“连接意外关闭”)smtplib。SMTPServer断开连接:连接意外关闭'

lhcgjxsq

lhcgjxsq1#

我没有看到它列在这里,但是你导入smtplib和ssl模块了吗?

相关问题