简体   繁体   English

有没有办法解决这个 smtp 连接错误?

[英]Is there a way I can solve this smtp connection error?

import smtplib


EMAIL_ADDRESS = '___@gmail.com'

PASSWORD = input(str("Enter Password: "))

with smtplib.SMTP('smtp.gmail.com', 587) as smtp:

     smtp.ehlo()

     smtp.starttls()

    smtp.login(EMAIL_ADDRESS, PASSWORD)
    print("Login Successful")

    subject = 'Grab dinner'
    body = 'How about dinner this saturday'
    msg = f'Subject{subject}\n\n Body{body}'

    smtp.sendmail(EMAIL_ADDRESS, '___@gmail.com', msg)

but this is the error i get ;但这是我得到的错误;

 raise SMTPConnectError(code, msg)

smtplib.SMTPConnectError: (451, b'Request action aborted on MFE proxy, SMTP server is not available.')

Your code to connect to smtplib works fine.您连接到 smtplib 的代码工作正常。 the likelihood is that there is some environmental issue like DNS settings that is affecting connectivity from your instance to gmail.可能存在一些环境问题,例如 DNS 设置,影响了从您的实例到 Gmail 的连接。 You can try these other answers on suggestions for where the configuration issue might lie.您可以尝试这些其他答案,了解有关配置问题可能出在哪里的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM