gpt4 book ai didi

python - 套接字错误 : [Errno 111] Connection refused

转载 作者:IT老高 更新时间:2023-10-28 20:34:32 28 4
gpt4 key购买 nike

我正在为 SMTP 使用简单的 python 库但是我收到了这个错误:

import smtplib
smtpObj = smtplib.SMTP('localhost')

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/smtplib.py", line 249, in __init__
(code, msg) = self.connect(host, port)
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

使用python-2.7

最佳答案

使用 Python 启动一个简单的 SMTP 服务器,如下所示:

python -m smtpd -n -c DebuggingServer localhost:1025

或者你也可以试试gmail smtp设置

server = smtplib.SMTP(host='smtp.gmail.com', port=587)

关于python - 套接字错误 : [Errno 111] Connection refused,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20349170/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com