import smtplib
my_email = "*******@gmail.com"
password = "***********"
with smtplib.SMTP("smtp.gmail.com") as connection:
connection.starttls()
connection.login(user=my_email, password=password)
connection.sendmail(from_addr=my_email, to_addrs="*******@yahoo.com",
msg="Subject:Hello\n\n This is the body of my email.")
In gmail the "less secure apps" feature was enabled. Conversely, in Yahoo, the "Generate App Password" feature was used and still got the same response for both instances.
There can be many reasons for this error - typically it means something has gone wrong in setting up the smtplib connection and your email hasn't set.
To get a more descriptive and helpful error message, you need to enable debugging.
To do that add, add this line of code:
connection.set_debuglevel(1)
That will print out much more descriptive debugger messages to the console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With