前两天设置的自动发送邮件的脚本,今天未发送.查看报错如下

1
2
3
4
5
6
7
8
9
File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known

google之,发现是连接sock端口连接失败,由于我用的是ubuntu的测试机,测试网络ok,就可能是防火墙的问题.关闭防火墙进行测试,发送ok.

1
ubuntu关闭防火墙命令:ufw disable