Gmail Mail Setting

Hello! I have been looking on the forums and tried to use the imap mail feature and I cannont get Gmail to work. I’ve looked at the posts in the forums and I can’t seem to find a solution. Each time I enter the credentials nothing happens. I do have a non-Gmail account working just fine. Below is a picture of my configuration. In the password fields, I have been trying to use the google generated a one-time app password with no luck. I am on a Bluehost server using let’s encrypt certificate. Any help would be appreciated!

Hi Alan and welcome to the forum!

After reading your question, the first thing that popped to my mind, was the Enable IMAP option in your Gmail account.

Please have a look at the following Google Support Link, follow these steps and try again in Nextcloud afterwards.

Google Suppor Link:

Thank you! Happy to be here and thank you for your response.

I did follow the instructions on the link, and I do have IMAP Enabled but no success. The fields go gray and I an not input anything for about 30 seconds and then it goes back. I have tried several of the settings, but no luck. Is there a log I and turn on or check to see why it times out or see errors after it attempts the connection?

1 Like

Hi Alan, i use this settings.

I’m having this same problem.

The Nextcloud UI for the email client isn’t so great; it tells you that it failed to communicate with the remote server, but you’re configuring 2 remote servers (SMTP and IMAP) and it doesn’t tell you which one is failing…

On G-Mail I enabled IMAP and from my Google Account settings I got an App Specific Password. In Mozilla Thunderbird I can configure things like this:


But when I configure the email app in NextCloud identically, it doesn’t work:

I don’t see any errors in /usr/share/webapps/nextcloud/data/nextcloud.log. Literally nothing shows up in the log file after I click the Connect button.

If I look at the Network tab in Firefox’s developer tools, I see the POST to apps/mail/api/accounts fails with status 400 Bad Request and the response payload {"message":"Creating account failed: Error connecting to mail server."}. The request payload looks OK, too:

   "accountName" : "FOO",
   "autoDetect" : false,
   "emailAddress" : "",
   "imapHost" : "",
   "imapPassword" : "SEKRET",
   "imapPort" : 993,
   "imapSslMode" : "ssl",
   "imapUser" : "",
   "smtpHost" : "",
   "smtpPassword" : "SEKRET",
   "smtpPort" : 587,
   "smtpSslMode" : "tls",
   "smtpUser" : ""

I followed the admin guide in the mail app’s source tree and increased the timeouts for imap (60) and smtp (20), and that didn’t help. I tried the link from the admin guide for the unlock captcha, but that seems to not apply if you’re using 2-factor auth + app specific password in GMail.

I’m using NextCloud v18.0.0 with Mail v1.0.0

More details.

I noticed @Sani provided a screenshot of a completely different section of NextCloud (Settings -> General -> Basic Settings -> Email server.

I have mine working here using Sendmail. When I configure for SMTP using GMail then I get an error that can’t be contacted:

A problem occurred while sending the email. Please revise your settings. (Error: Connection could not be established with host :stream_socket_client(): unable to connect to tcp:// (Connection timed out))

Unfortunately there’s nothing of interest in the Developer Tools -> Network tab and like before, nothing shows in data/nextcloud.log

I suspect solving this error will also solve the issue in the Mail App, but I’m not really sure where to go.

I was able to setup Settings -> General -> Basic Settings -> Email server -> SMTP with a different SMTP server, so this seems to be a Nextcloud + GMail specific issue (or maybe PHP + GMail?).

So here’s something interesting… I completely disabled IPv6 on my nextcloud server and now it’s working.

Solution for me was to enable “Less secure apps” setting on Gmail:

(credit to some other post here but I lost the tab)


Also, it is impossible to enable the “Less secure apps” option if you have 2FA on your Google account.

Do you know if Nextcloud Mail is planning on implementing 2FA for Google accounts?


I feel like this is very important and should be implemented.

If you have 2FA enabled in gmail, then you can create a App Password for Nextcloud Mail and use that password instead of your regular gmail login password.

Follow the link below for instructions on how the create and use App passwords:


Thank you, that’s what I needed!

I have 2FA enabled on my gmail, so I had to create an app-specific password at and then used that instead of my real password.


Ho lo stesso problema. Non riesco a sincronizzare la mia casella di posta gmail

This worked for us - Less Secure Apps kicks out most non Google apps connecting to pop or just smtp in this case. Thanks for reminding us to set this in Google Admin


I was having issues connecting to my Gmail with Nextcloud, and despite having properly enabled IMAP, no 2FA, less secure apps allowed, I was still having issues.

I followed the instructions here:

Under Troubleshooting step 2, theres the one that solved it for me:

Not much explanation here, just a page with a link, clicked on it and viola! It worked.

Hope it helps others.

how did you do that?

Thank you for your information :slight_smile:

1 Like