Python 发送邮件 socket.gaierror: [Errno 11004] getaddrinfo failed

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python 发送邮件 socket.gaierror: [Errno 11004] getaddrinfo failed相关的知识,希望对你有一定的参考价值。

 

 

======================================

Traceback (most recent call last):
  File "D:/soft/test.py", line 140, in <module>
    main_runnow()
  File "D:/soft/test.py", line 133, in main_runnow
    sendmail(str(disk_free),files)
  File "D:/soft/test.py", line 42, in sendmail
    smtp = smtplib.SMTP_SSL("smtp.163.com",994) #实例化smtp服务器
  File "C:\\Python38\\lib\\smtplib.py", line 1043, in __init__
    SMTP.__init__(self, host, port, local_hostname, timeout,
  File "C:\\Python38\\lib\\smtplib.py", line 255, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\\Python38\\lib\\smtplib.py", line 339, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\\Python38\\lib\\smtplib.py", line 1049, in _get_socket
    new_socket = socket.create_connection((host, port), timeout,
  File "C:\\Python38\\lib\\socket.py", line 787, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "C:\\Python38\\lib\\socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed

======================================

可能做了设置,不能访问某些网站IP等。

比如不能访问 smtp.163.com

======================================

 

以上是关于Python 发送邮件 socket.gaierror: [Errno 11004] getaddrinfo failed的主要内容,如果未能解决你的问题,请参考以下文章

python发送邮件

python发送邮件(转)

如何用python通过163发送邮件

Python 发送邮件

python发送邮件

Python发送邮件