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

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

Error:
[Running] python -u "c:\Telepin_14012021\Telepin_Ottawa\Telepin_work\ottawa\managed_service\email_test.py" Traceback (most recent call last): File "c:\Telepin_14012021\Telepin_Ottawa\Telepin_work\ottawa\managed_service\email_test.py", line 6, in <module> with smtplib.SMTP('smtp.gmail.com',587) as smtp: File "C:\Python\Python39\lib\smtplib.py", line 253, in __init__ (code, msg) = self.connect(host, port) File "C:\Python\Python39\lib\smtplib.py", line 339, in connect self.sock = self._get_socket(host, port, self.timeout) File "C:\Python\Python39\lib\smtplib.py", line 310, in _get_socket return socket.create_connection((host, port), timeout, File "C:\Python\Python39\lib\socket.py", line 843, in create_connection raise err File "C:\Python\Python39\lib\socket.py", 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('smtp.gmail.com',587) as smtp: 
    smtp.ehlo()
    smtp.starttls()
    smtp.eclo()
    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.
Reply
#2
Line 6 it should be smtp.ehlo().
Reply
#3
Hi

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 .
Reply


Forum Jump:

User Panel Messages

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