简体   繁体   English

使用 IMAP 阅读 gmail 失败

[英]reading gmail is failing with IMAP

I am running a cron job which executes the python script for reading gmail (2 min interval).我正在运行一个 cron 作业,它执行用于读取 gmail 的 python 脚本(2 分钟间隔)。 I have used imaplib for reading the new mails.我使用 imaplib 来阅读新邮件。 This was working fine until yesterday.直到昨天,这一切都很好。 Suddenly its throwing below error突然它抛出错误

imaplib.error: [AUTHENTICATIONFAILED] Invalid credentials (Failure) imaplib.error:[AUTHENTICATIONFAILED] 无效凭据(失败)

and sometimes i am getting the below error有时我会收到以下错误

raise self.abort(bye[-1]) imaplib.abort: [UNAVAILABLE] Temporary System Error raise self.abort(bye[-1]) imaplib.abort: [UNAVAILABLE] 临时系统错误

When i run the same script on a different machine.当我在另一台机器上运行相同的脚本时。 Its working fine.它工作正常。 I am assuming that the host has been blacklisted or something like that.我假设主机已被列入黑名单或类似的东西。

What are my options ?我有什么选择?

I cant generate the Credentials (Gmail API) as this is under company domain account.我无法生成凭据(Gmail API),因为这是在公司域帐户下。

try with:尝试:

1) https://myaccount.google.com/lesssecureapps?pli=1 1) https://myaccount.google.com/lesssecureapps?pli=1

2) Gmail Settings -> Forwarding and POP / IMAP -> IMAP Acess to Enable IMAP 2) Gmail 设置 -> 转发和 POP / IMAP -> IMAP 访问以启用 IMAP

Some apps and devices use less secure sign-in technology.某些应用和设备使用安全性较低的登录技术。 So we need to enable Less secure app access option from gmail account.因此,我们需要从 gmail 帐户启用Less secure app access选项。

Steps:脚步:

  1. Login into Gmail登录 Gmail
  2. Go to Google Account转到 Google 帐户
  3. Navigate to Security section导航到Security部分
  4. Turn on access for Less secure app accessLess secure app access打开访问权限

By following above steps, issue will be resolved.按照上面的步骤,问题就解决了。

Got the same error and it was fixed by getting the new google app password.得到了同样的错误,并通过获取新的谷歌应用密码来修复。 Maybe this will work for someone也许这对某人有用

This can be solved in two steps:这可以分两步解决:

Thanks guys.多谢你们。 Its working now.它现在工作。 The issue was that the google blocked our network.. because of multiple attempts.问题是谷歌阻止了我们的网络..由于多次尝试。 I tried that unlock URL from a different URL and it didnt work.我尝试从不同的 URL 解锁 URL,但它没有工作。 The catch is that, we have to run that URL in the machine where you are trying to run the script.问题是,我们必须在您尝试运行脚本的机器上运行该 URL。 Hope it may help someone :)希望它可以帮助某人:)

Ensure you have entered the right password

Even after that if it is not working
  • Enable the IMAP Access at: Gmail Settings> Forwarding and POP / IMAP> IMAP Acess在以下位置启用 IMAP 访问:Gmail 设置> 转发和 POP / IMAP> IMAP 访问

  • Enable 2-factor authentication for the google account为 google 帐户启用 2 因素身份验证

  • then generate an app-specific password ( https://myaccount.google.com/apppasswords )然后生成一个应用专用密码 ( https://myaccount.google.com/apppasswords )

  • Use this newly generated password for imap login使用这个新生成的密码进行 imap 登录

Google Gmail - Security - Less secure app access ... won't work anymore !谷歌 Gmail - 安全 - 不太安全的应用程序访问......不再起作用了!

See https://support.google.com/accounts/answer/6010255?hl=en请参阅https://support.google.com/accounts/answer/6010255?hl=en

“To help keep your account secure, from May 30, 2022, ​​Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.” “为了帮助确保您的帐户安全,从 2022 年 5 月 30 日起,Google 不再支持使用第三方应用程序或设备,这些应用程序或设备要求您仅使用您的用户名和密码登录您的 Google 帐户。”

Regards Diego问候迭戈

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM