I had the same error and found another solution. I added debugging information to the host:
"{imap.gmail.com:993/debug/imap/ssl/novalidate-cert}INBOX";
When I read the php error log I found
Unknown: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (errflg=1) in Unknown on line 0
Open the link and follow the instructions. Search
Your application may not support the latest security standards. Try changing a few settings to allow less secure applications to access your account.
Click the link and enable less secure access to applications.
Then it works for me.
Mrgapo
source share