Python Forum
python with gmail in windws10
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python with gmail in windws10

i am using for first time python to send email in my small code and i am getting an error

[Running] python -u "c:\Telepin_14012021\Telepin_Ottawa\Telepin_work\ottawa\managed_service\" Traceback (most recent call last): File "c:\Telepin_14012021\Telepin_Ottawa\Telepin_work\ottawa\managed_service\", line 6, in <module> with smtplib.SMTP('',587) as smtp: File "C:\Python\Python39\lib\", line 253, in __init__ (code, msg) = self.connect(host, port) File "C:\Python\Python39\lib\", line 339, in connect self.sock = self._get_socket(host, port, self.timeout) File "C:\Python\Python39\lib\", line 310, in _get_socket return socket.create_connection((host, port), timeout, File "C:\Python\Python39\lib\", line 843, in create_connection raise err File "C:\Python\Python39\lib\", line 831, in create_connection sock.connect(sa) 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
my code is :
import smtplib

with smtplib.SMTP('',587) as smtp: 
    smtp.login('[email protected]','XXXXX')
    subject = 'My first email'
    body = 'how are you'
    msg = f'Subject: {subject}\n\n{body}'
    smtp.sendmail('source','dest', msg)
buran write Jan-20-2021, 08:27 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Line 6 it should be smtp.ehlo().

issue was with VPN and VPN was not allowing me to send email , after i did disable it it is working fine

of course i did change the line 6 .
Thanks a lot .

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020