我正在尝试通过Python中的“localhost”发送电子邮件,但它一直给我一个“错误61”

时间:2011-05-06 02:39:43

标签: python email localhost

我正在运行Mac OS X并使用postfix来启用localhost。 这是我收到的错误消息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 239, in __init__
    (code, msg) = self.connect(host, port)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 295, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 273, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 61] Connection refused

2 个答案:

答案 0 :(得分:2)

首先使用netstat验证SMTP服务器是否绑定到适当接口的端口25。

答案 1 :(得分:0)

检查后缀日志文件,该文件可能位于/var/log/mail或类似名称,具体取决于您安装后缀的方式。