import smtplib
EMAIL_ADDRESS = '[email protected]'
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, '[email protected]', 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.