我已经尝试了这个问题的所有答案,但仍然无法弄清楚为什么会显示特定的错误。
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
这是我输入的代码:
import smtplib
SERVER = "localhost"
FROM = "frommail@example.com"
TO = ["tomail@example.com"] # must be a list
SUBJECT = "Hello!"
TEXT = "This message was sent with Python's smtplib."
# Prepare actual message
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# Send the mail
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, message)
server.quit()