如何解决SMTP 发送:“getaddrinfo 失败”
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.")
以上代码产生以下错误。我的操作系统是 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",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
我该如何解决这个错误
解决方法
将 ServiceBase
替换为 smtp.gamil.com
。
smtp.gmail.com
(2021-01-07T13:08+00:00) 没有 A
/AAAA
记录。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。