gmail login failure using python and imaplib gmail login failure using python and imaplib python python

gmail login failure using python and imaplib


You can try to turn on this: https://www.google.com/settings/security/lesssecureappsThis action solved the same problem for me.


If you want to avoid this error without compromising your account's security, use OAuth to authenticate. The protocol is documented here, and there is Python sample code that shows the use of XOAUTH2 with imaplib.

Independent of this, you should consider enabling two-step verification on your account to make it more secure. If you do, you can use an App Password to connect to IMAP, which might also avoid the above warning.


With the new gmail´s update, some mail servr or apps get blocked due to the new gmails security settings. To solve this, I went to https://www.google.com/settings/security page and 'enabled' Access for less secure apps.