简体   繁体   中英

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. the likelihood is that there is some environmental issue like DNS settings that is affecting connectivity from your instance to gmail. You can try these other answers on suggestions for where the configuration issue might lie.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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