python smtp 发送邮件 [WinError 10060] A connection attempt failed … has failed to respond
本文关键字: email, python, SMTP在ASW上部署了一个数据监控系统,但是SMTP发送邮件提示
[WinError 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
发送邮件在本地是正常发送的,所以考虑是ip白名单或者端口的问题。
解决方案:修改25端口到465
smtpObj = smtplib.SMTP()
smtpObj = smtplib.SMTP_SSL(mail_host) # 此段代码表示使用ssl协议,163邮箱用465或994端口,否则用25端口
# 设置发件人邮箱的域名和端口,端口地址为25
smtpObj.connect(mail_host, 465)