Python socket OSError: [Errno 101] Network is unreachable

python发送邮箱 之后出现上面错误。

现象:使用windows发送没问题。。放到centos 执行就报错。

解决方案 使用 SMTP_SSL 加ehlo命令

  smtp = smtplib.SMTP_SSL("smtp.qq.com")
    # 我们用set_debuglevel(1)就可以打印出和SMTP服务器交互的所有信息。
    # smtp.set_debuglevel(1)
    smtp.ehlo("smtp.qq.com")
    smtp.login(username, password)
    smtp.sendmail(sender, receiver, msg.as_string())
    smtp.quit()

国内都是渣渣。。我从国外找的。。。

猜你喜欢

转载自blog.csdn.net/mp624183768/article/details/105970608
今日推荐