This is my code
import smtplib
from datetime import datetime
print("Sending Mail")
with smtplib.SMTP('smpt.gmail.com', 587) as smtp:
smtp.ehlo()
smtp.starttls()
smtp.ehlo()
smtp.login('gmail', 'password')
print("Logged In")
subject = "Current Time: " + datetime.now.strftime("%d/%m/%Y %H:%M:%S")
smtp.sendmail('myemail@gmail.com', 'myemail@gmail.com', "hello")
print("Sent Email")
I'm trying to send an email through gmail using smtplib, this is the error I get:
Sending Mail
Traceback (most recent call last):
File "c:/Users/12488/Downloads/Key Logger/keylog.py", line 43, in <module>
with smtplib.SMTP('smpt.gmail.com', 587) as smtp:
File "C:\Users\12488\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 253, in __init__
(code, msg) = self.connect(host, port)
File "C:\Users\12488\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 339, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Users\12488\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 308, in _get_socket
return socket.create_connection((host, port), timeout,
File "C:\Users\12488\AppData\Local\Programs\Python\Python38\lib\socket.py", line 787, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\12488\AppData\Local\Programs\Python\Python38\lib\socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
I made sure less secure devices is checked on gmail but I haven't tried every solution on the internet because I'm new to python and this is my first time using smtp and I don't get a lot of them, I think this has something to do with socket because that's another popular python module from what I've read but I don't know much about it and I'm not sure, if anyone can simplify what is wrong and explain it to me like I'm a 5 year old, it would be greatly appreciated.
You're using an incorrect domain which is not being resolved by DNS servers.
smpt.gmail.com
should be:
smtp.gmail.com