25

I am running a cron job which executes the python script for reading gmail (2 min interval). I have used imaplib for reading the new mails. This was working fine until yesterday. Suddenly its throwing below error

imaplib.error: [AUTHENTICATIONFAILED] Invalid credentials (Failure)

and sometimes i am getting the below error

raise self.abort(bye[-1]) imaplib.abort: [UNAVAILABLE] Temporary System Error

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.

6
  • Gmail has set some internal limitations like downloading. Check that limit. support.google.com/a/answer/1071518?hl=en Gmail will not showing appropriate error. Another machine IP address is different so that same code is working on his machine. Commented Oct 14, 2015 at 7:57
  • bandwidth cannot be exceeding the allowed limit. as there are only 3-4 mails from yesterday. Commented Oct 14, 2015 at 8:15
  • Take call from google support, may your IP is blocked. It happened with me some months ago. Commented Oct 14, 2015 at 9:46
  • Do you have scope mail.google.com. If your account is locked, you can unlock it using this link om4.com.au/google-apps-gmail-invalid-credentials-unlock-captcha Commented Oct 14, 2015 at 23:51
  • 2
    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. The catch is that, we have to run that URL in the machine where you are trying to run the script. Hope it may help someone :) Commented Nov 3, 2015 at 6:27

9 Answers 9

38

try with:

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

2) Gmail Settings -> Forwarding and POP / IMAP -> IMAP Acess to Enable IMAP

Sign up to request clarification or add additional context in comments.

6 Comments

Hi, welcome to Stack Overflow. Please provide context for links. Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. stackoverflow.com/help/how-to-answer
Thank you! None of these answers helped but this one. Wish it was marked as the right answer.
this answer should be the accepted one since it is probably the most prevalent cause for the issue.
As like @Nv7, the above answers does not work for me too.
Google Account setting "Less secure app access" does no longer work (February 2023). Using the link above shows the message "This setting is no longer available".
|
26

Some apps and devices use less secure sign-in technology. So we need to enable Less secure app access option from gmail account.

Steps:

  1. Login into Gmail
  2. Go to Google Account
  3. Navigate to Security section
  4. Turn on access for Less secure app access

By following above steps, issue will be resolved.

1 Comment

Seems this option isn't available anymore.
7

Enable 2FA and generate App passwords, use this generated password with IMAP.

step 1: Enable 2FA

step 2: Generate App passwords

step 3: Enable IMAP access

1 Comment

my method stopped working. I have used this and had good results.
6
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

  • Enable 2-factor authentication for the google account

  • then generate an app-specific password (https://myaccount.google.com/apppasswords)

  • Use this newly generated password for imap login

Comments

3

This can be solved in two steps:

Comments

2

Got the same error and it was fixed by getting the new google app password. Maybe this will work for someone

Comments

1

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. The catch is that, we have to run that URL in the machine where you are trying to run the script. Hope it may help someone :)

Comments

1

Google Gmail - Security - Less secure app access ... won't work anymore !

See 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.”

Regards Diego

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
0

Now Google has created set of libraries to read Gmail data, after creating project in API and Services on Google Cloud. Following link contains python quickstart guide for same: https://developers.google.com/gmail/api/quickstart/python

After following the steps, when I got a link from my script to proceed through Browser after logging I was getting "Access Blocked: project has not completed the Google Verification process". Then I found this Youtube video, which solved this issue as well.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.