Unable to connect to Gmail with "Mail server denied authentication" error


I’m trying to connect to my Gmail account but without success.

The error is: Creating account failed: Could not connect to IMAP host imap.gmail.com:993: Mail server denied authentication.

Note that it’s not a credentials issue because if in the case I enter a wrong password the error message is different: Could not connect to IMAP host imap.gmail.com:993: Authentication failed.

On the Google side IMAP is enabled and I’ve allowed less secure applications. I know that parameter is working because I can now connect Kmail to my Gmail account without any problem (that parameter is mandatory in order to allow Kmail to work with Gmail, which is not the case for Thunderbird for example).

I’m using the classic IMAP settings: imap.gmail.com on port 993 with SSL/TLS.

I’ve tried to set my log level to debug but I didn’t see another message from the mail app.

Anyone has an idea ?

My NC version is 20 and mail app version is 1.7.2.

Thanks for your help, Vincent.

Have you seen this thread:

Yes, I’ve seen it but from what I’ve understood the “app password” is useful for people who have the “2 Factor Auth” enabled on Google side, which is not my case.

App passwords are always useful, to prevent updating all related accounts if you change the your Nextcloud password :wink:

1 Like

Yep, @turman try with app passwords nevertheless. Also you can experiment with less secure apps. Sometimes Google acts a bit unexpected and inconsistent.

The less secure apps option is already enabled (I set it to connect Kmail to my Gmail account and it works).

I can try the app password but for that I need apparently to enable the 2 factor auth which would annoy me…

I guess other people has managed to connect NC mail app to their Gmail account with their regular password (ie. not the app password), right ?

There is no way to debug or understand the authentification problem ? Setting the log level to debug didn’t give some additionnal infos…

No, you can always use app specific passwords. There is no direct relation to any 2FA mechanism.

But Google says there is a strong relation between app passwords and 2FA:

An App Password is a 16-digit passcode that gives a less secure app or device permission to access your Google Account. App Passwords can only be used with accounts that have [2-Step Verification] turned on.

Finally I activated 2FA so I was able to generate an app password, and now NC mail can connect !

I’m still interested to know if most people had to go this way or if some ones manage to use their classic password.

Thank you anyway for your help, Vincent

1 Like