2

行 all から始まるすべての行は、エラー Errno 10060 またはエラー 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)

手伝ってくれる?私は些細なことを見逃しているに違いない... エラーメッセージの全文:

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
4

3 に答える 3

2

smtplib.SMTP_SSL()TLS接続に使用します。

于 2012-08-13T11:55:02.753 に答える
2

以下のすべてのコマンドに問題はありません。私の問題は確かに IP 制限が原因です。ご回答ありがとうございます。

于 2012-08-14T14:39:23.120 に答える
1

またはserver = smtplib.SMTP('smtp.gmail.com:25')通常の接続に使用

ポート25からのTLSが必要な場合は、追加するだけです

server.starttls() 

最初の行の後。

ps: ポート 25 がデフォルトであるため、以下は同等です。

server = smtplib.SMTP('smtp.gmail.com')
server.starttls() 
于 2012-08-13T12:00:06.840 に答える