尝试连接时出现SMTP python traceback错误

时间:2012-08-03 21:34:12

标签: python smtp

所以我收到了这个错误:

import smtplib
server = smtplib.SMTP()
server.connect()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/smtplib.py", line 309, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 284, in _get_socket
   return socket.create_connection((port, host), timeout)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 111] Connection refused

不完全确定原因:s有人可以帮我一点吗?

2 个答案:

答案 0 :(得分:2)

您正在尝试连接'localhost',端口25(.connect()的默认值),并且没有服务器在那里监听。因此拒绝连接。

答案 1 :(得分:0)