本文介绍了SMTPAuthenticationError 5.7.14请通过网络浏览器登录\ n5.7.14的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我查看并审查了许多与此问题相关的问题时,我一直在努力寻找适用于我的案子的解决方案.我有一个脚本,可以定期将报告发送到收件人列表.直到今天凌晨4点,一切都运转良好,当时我检查了收件箱,但报告没有出现.

I have been struggling in finding a solution that can be applied to my case, as I viewed and reviewed many questions related to this issue. I have a script which sends periodically reports to a list of recipients. Everything worked fine until today 4 am, when I checked my inbox and the reports didn't come.

通过调试代码:

import smtplib
username="my.user.account@gmail.com"
password="my.correct.password"

server=smtplib.SMTP('smtp.gmail.com',587)
server.ehlo()
server.starttls()
server.ehlo()
server.login(username,password)

#if login worked, it should send a message, but it is not working, so I will suppress this part

server.quit()

我收到以下(旧的)结果:

I receive the following (old known) result:

我尝试过的事情

允许安全性较低的应用(如 https://中所述) www.google.com/settings/security/lesssecureapps ):自创建帐户以来,此标志设置为true.

Allow less secure apps (as indicated in https://www.google.com/settings/security/lesssecureapps): This flag was set to true since I created the account.

禁用验证码(如 https://accounts.google.com/中所示DisplayUnlockCaptcha ):多次访问此URL.没有运气.

Disable Captcha (as indicated in https://accounts.google.com/DisplayUnlockCaptcha): Visited this URL several times. No luck.

通过浏览器登录:在从任何计算机通过任何Internet浏览器登录时,它都可以正常工作,尽管在第一次时,我不得不插入发送到该帐户的辅助电话的代码.

Login via browser: It works fine, when logging via any Internet Browser from any computer, although in the first times I had to insert a code sent to the account's recovery phone.

我遇到了其他可以尝试的方法,但是我不确定它是否可以工作:

I came across other things I could try, but I am not sure it could work:

  • 特定的应用密码
  • Oauth2
  • 更改或重置密码

我可能会尝试使用oauth2,但是它需要更改我的代码,由于服务器的某些限制,我想避免这样做.真正令我惊讶的是,它工作正常,突然停止了!

I will probably try oauth2, however it would require a change in my code, which I want to avoid due to some restrictions in the server. What really freaks me out is that it was working fine and suddenly stopped!

任何帮助将不胜感激!

推荐答案

我已经使用Google Gmail API解决了此问题.似乎Google阻止或限制了我通过未知设备登录我的帐户,因为我只能通过浏览器登录,并且在确认电话号码和SMS发送的代码后才能登录.

I have solved this using the Google Gmail API. It seems Google has either blocked or limited logins for my account through unknown devices, as I could login only via the browser and after I confirmed the telephone number and an code sent by SMS.

因此,我决定放弃使用smtplib,并使用Google用于Gmail的API来实现访问权限: https://developers.google.com/api-client-library/python/ https://developers.google.com/gmail/api/guides/sending

So I decided to give up using smtplib and implemented the access using the API Google uses for Gmail:https://developers.google.com/api-client-library/python/https://developers.google.com/gmail/api/guides/sending

希望这可以帮助遇到此问题的其他人.

Hope this helps other who had trouble with this issue.

这篇关于SMTPAuthenticationError 5.7.14请通过网络浏览器登录\ n5.7.14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 01:27