SMTPAuthenticationError 5.7.14请通过网络浏览器登录\ n5.7.14 [英] SMTPAuthenticationError 5.7.14 Please log\n5.7.14 in via your web browser

查看:168
本文介绍了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:

(250,b'smtp.gmail.com为您服务,[SERVERIP] \ nSIZE 35882577 \ n8BITMIME \ nSTARTTLS \ nEHANCEDSTATUSCODES \ nPIPELINING \ nCHUNKING \ nSMTPUTF8') (220,b'2.0.0准备启动TLS')(250,b'smtp.gmail.com 服务,[SERVERIP] \ nSIZE 35882577 \ n8BITMIME \ nAUTH LOGIN PLAIN XOAUTH2 普通客户代币持有人 XOAUTH \ nENHANCEDSTATUSCODES \ nPIPELINING \ nCHUNKING \ nSMTPUTF8') 追溯(最近一次通话最后一次):文件",第6行,在 server.login(用户名,密码)文件"C:\ Python \ Python36 \ lib \ smtplib.py",第729行,登录 在登录时引发last_exception文件"C:\ Python \ Python36 \ lib \ smtplib.py",第720行 auth中的文件"C:\ Python \ Python36 \ lib \ smtplib.py",第641行 引发SMTPAuthenticationError(code,resp)smtplib.SMTPAuthenticationError:(534,b'5.7.14 请 通过网络浏览器登录\ n5.7.14,然后重试.\ n5.7.14了解 更多信息,请参见\ n5.7.14 https://support.google.com/mail/answer/78754 r131sm2964505vkr.40-gsmtp')

(250, b'smtp.gmail.com at your service, [SERVERIP]\nSIZE 35882577\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8') (220, b'2.0.0 Ready to start TLS') (250, b'smtp.gmail.com at your service, [SERVERIP]\nSIZE 35882577\n8BITMIME\nAUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8') Traceback (most recent call last): File "", line 6, in server.login(username,password) File "C:\Python\Python36\lib\smtplib.py", line 729, in login raise last_exception File "C:\Python\Python36\lib\smtplib.py", line 720, in login initial_response_ok=initial_response_ok) File "C:\Python\Python36\lib\smtplib.py", line 641, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (534, b'5.7.14 Please log\n5.7.14 in via your web browser and then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 r131sm2964505vkr.40 - gsmtp')

我尝试过的事情

允许安全性较低的应用(如 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆