尝试使用 SMTP 登录 Gmail 帐户时,出现此错误消息:
SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted.
导致错误的代码:
import smtplib
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login("[email protected]", "your_password")
message = "TEST"
server.sendmail("[email protected]", "[email protected]", message)
server.quit()
自 2022 年 5 月起,Google 已禁用启用安全性较低的应用程序的功能。因此,之前启用安全性较低的应用程序的解决方案不再有效。
步骤:
致谢:来源链接
显然谷歌已经改变了设置。因此,从“2023 年 9 月”开始,您要做的就是按照以下步骤操作:
************************ 重要************************
之后要确保的两件重要事情是(这可能会导致错误):
希望能解决