OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

TimeoutError: [WinError 10060] when sending Email from Gmail to myself

  • Thread starter Thread starter Tom Osborne
  • Start date Start date
T

Tom Osborne

Guest
I am currently following tutorials to try to send emails from Gmail using smtplib. I keep getting the 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

I am afraid that this might be something to do with Gmail updating its security to prevent people using App Passwords on Google accounts.

Any help much appreciated.

Here is the code I followed, the password was generated using the App Passwords function on Gmail:

Code:
import smtplib 
from email.mime.text import MIMEText

password = "XXXXXXXXX"
subject = "Email Subject"
body = "This is the body of the text message"
sender = "[email protected]"
recipients = sender
def send_email(subject, body, sender, recipients, password):
    msg = MIMEText(body)
    msg\["subject"\] = subject
    msg\["From"\] = sender
    msg\["To"\] = ",".join(recipients)

    with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp_server:
        smtp_server.login(sender, password)
        smtp_server.sendmail(sender, recipients,msg.as_string())
    print("Message Sent!")

send_email(subject, body, sender, recipients, password)

As described, every time I try to run it, I get the 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
<p>I am currently following tutorials to try to send emails from Gmail using smtplib. I keep getting the error:</p>
<p>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</p>
<p>I am afraid that this might be something to do with Gmail updating its security to prevent people using App Passwords on Google accounts.</p>
<p>Any help much appreciated.</p>
<p>Here is the code I followed, the password was generated using the App Passwords function on Gmail:</p>
<pre><code>import smtplib
from email.mime.text import MIMEText

password = "XXXXXXXXX"
subject = "Email Subject"
body = "This is the body of the text message"
sender = "[email protected]"
recipients = sender
def send_email(subject, body, sender, recipients, password):
msg = MIMEText(body)
msg\["subject"\] = subject
msg\["From"\] = sender
msg\["To"\] = ",".join(recipients)

with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp_server:
smtp_server.login(sender, password)
smtp_server.sendmail(sender, recipients,msg.as_string())
print("Message Sent!")

send_email(subject, body, sender, recipients, password)
</code></pre>
<p>As described, every time I try to run it, I get the error:</p>
<p><code>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</code></p>
Continue reading...
 

Latest posts

Top