-1
import smtplib

def sendEmail(receiver,subject,message):
    server = smtplib.SMTP('smtp.gamil.com',587)
    server.ehlo()
    server.starttls()
    server.login("botsinhala@gmail.com",password)
    server.sendmail("botsinhala@gmail.com",receiver,message)
    
    print("succesful")

sendEmail("gadjetrathnayake@gmail.com","testing bot","Hi, This is a testing message i'm sending to you.")

above code is generating the following error. My OS is windows 10.

Traceback (most recent call last):
  File "D:/MY CHANNEL/python tricks/Email bot 1/tttttttttttttttttttttttt.py", line 17, in <module>
    sendEmail("andrewhawkins@gmail.com","testing bot","Hi, This is a testing message i'm sending to you.")
  File "D:/MY CHANNEL/python tricks/Email bot 1/tttttttttttttttttttttttt.py", line 5, in sendEmail
    server = smtplib.SMTP('smtp.gamil.com',587)
  File "C:\Users\Dell Pc\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Users\Dell Pc\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py", line 336, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Users\Dell Pc\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py", line 307, in _get_socket
    self.source_address)
  File "C:\Users\Dell Pc\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "C:\Users\Dell Pc\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

How can I fix this error

AnFi
  • 10,493
  • 3
  • 23
  • 47
  • Please search for if this question has been asked before https://stackoverflow.com/questions/18400208/socket-gaierror-errno-11001-getaddrinfo-failed – William Baker Morrison Jan 07 '21 at 11:08
  • Yes. when I googled I saw that. Even after correcting those my program didn't executed correctly. that's why I asked it here. Thank You. Your last comment was very useful. – gadjet's garage Jan 07 '21 at 13:53

1 Answers1

0

Replace smtp.gamil.com by smtp.gmail.com.

There are no A/AAAA records for smtp.gamil.com (2021-01-07T13:08+00:00).

AnFi
  • 10,493
  • 3
  • 23
  • 47
  • Thank you very much. Honestly it was the mistake, After correcting it, every thing went smoothly and program ended successfully. – gadjet's garage Jan 07 '21 at 13:51