Uncategorized

Python smtplib: Unable to send email from gmail to yahoo due to TimeoutError and SMTPConnectError


The code keeps bringing the TimeoutError and I have shutoff my firewall, used app password and so on:

CODE:

import smtplib
my_email="[email protected]"
password = "xxxxxxxxxxx"
connection = smtplib.SMTP("smtp.gmail.com")
connection.starttls() 
connection.login(user=my_email, password=password)
connection.sendmail(from_addr=my_email, to_addrs="[email protected]", msg="Hello World!")
connection.close()

ERROR:

TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

And when I add the port = 587 argument, it brings this error instead:

smtplib.SMTPConnectError: (421, b'Service not available')

Tried to use smtplib to send email from a gmail to a yahoo mail account. What I expected was a delivered message to the yahoo mail but I encountered this error instead.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *