Python 尝试通过 Hotmail 发送电子邮件时出错。暂停

Python Error trying to send email by Hotmail. TImeout

我的代码如下:

我尝试发送电子邮件时总是收到此错误。你能帮帮我吗

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

我建议阅读位于 https://docs.python.org/3/library/smtplib.html

的手册中的示例

您需要确保您的防火墙操作系统和 LAN 路由器允许端口 25 上的传出流量。

此外,根据手册设置 verbose 调试级别 server.set_debuglevel(1)

尝试使用终端命令通过 localhost 发送测试电子邮件,以确保 os 确实可以发送电子邮件,并且它不是 python 代码问题。