为什么要发分为两篇博客来写呢?是不是再默默的对小孤碎碎念呢,来啦来啦~
1. 如果报错信息为:ValueError: server_hostname cannot be an empty string or start with a leading dot.
不要慌,不慌,我们不慌~
# 改动这句代码
server = smtplib.SMTP_SSL()
# 在括号内加入host参数
server = smtplib.SMTP_SSL(smtp_server)
2. 如果报错信息为: smtplib.SMTPException: No suitable authentication method found
继续不慌~
# 在登录(login)之前调用starttls()方法就可以了。也就是在代码中加入这样一行:
server.starttls()
如果是其他问题,可以尝试改一改端口号哈~