Hi
i am using for first time python to send email in my small code and i am getting an error
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 : 1 2 3 4 5 6 7 8 9 10 11 |
import smtplib with smtplib.SMTP( 'smtp.gmail.com' , 587 ) as smtp: smtp.ehlo() smtp.starttls() smtp.eclo() smtp.login( 'XXXXX@gmail.com' , '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.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.