SMTP 发送:“getaddrinfo 失败”

问题描述

import smtplib

def sendEmail(receiver,subject,message):
    server = smtplib.SMTP('smtp.gamil.com',587)
    server.ehlo()
    server.starttls()
    server.login("[email protected]",password)
    server.sendmail("[email protected]",receiver,message)
    
    print("succesful")

sendEmail("[email protected]","testing bot","Hi,This is a testing message i'm sending to you.")

以上代码产生以下错误。我的操作系统是 Windows 10。

Traceback (most recent call last):
  File "D:/MY CHANNEL/python tricks/Email bot 1/tttttttttttttttttttttttt.py",line 17,in <module>
    sendEmail("[email protected]",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,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,family,type,proto,flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

我该如何解决这个错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)