本文介绍了python的smtplib无法连接到Gmail,mail.ru或其他任何东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从行开始的所有行都返回错误Errno 10060或错误Errno 10061:

All lines starting from line all return an error Errno 10060 or an error Errno 10061:

import smtplib
server = smtplib.SMTP('smtp.gmail.com:465')
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer = smtplib.SMTP("smtp.gmail.com", 465)
mailServer = smtplib.SMTP("smtp.mail.ru", 25)
mailServer = smtplib.SMTP("smtp.mail.ru", 2525)

你能帮忙吗?我必须错过一些微不足道的东西......错误消息已满:

Could you help? I must be missing something trivial... Error messages in full:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\smtplib.py", line 242, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python27\lib\smtplib.py", line 302, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\lib\smtplib.py", line 277, in _get_socket
return socket.create_connection((port, host), timeout)
File "C:\Python27\lib\socket.py", line 571, in create_connection
raise err
socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\smtplib.py", line 242, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python27\lib\smtplib.py", line 302, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\lib\smtplib.py", line 277, in _get_socket
return socket.create_connection((port, host), timeout)
File "C:\Python27\lib\socket.py", line 571, in create_connection
raise err
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it


推荐答案

下面的所有命令都没有错;我的问题确实是由知识产权限制引起的。感谢您的答复。

There is nothing wrong with all commands below; my issue is indeed caused by IP restrictions. Thanks for all your answers.

这篇关于python的smtplib无法连接到Gmail,mail.ru或其他任何东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 01:23