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: https://support.google.com/mail/answer/7126229?hl=en

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" : "FOO@gmail.com",
   "imapHost" : "imap.gmail.com",
   "imapPassword" : "SEKRET",
   "imapPort" : 993,
   "imapSslMode" : "ssl",
   "imapUser" : "FOO@gmail.com",
   "smtpHost" : "smtp.gmail.com",
   "smtpPassword" : "SEKRET",
   "smtpPort" : 587,
   "smtpSslMode" : "tls",
   "smtpUser" : "FOO@gmail.com"
}

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 smtp.gmail.com can’t be contacted:


A problem occurred while sending the email. Please revise your settings. (Error: Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to tcp://smtp.gmail.com:587 (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:
https://myaccount.google.com/lesssecureapps

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

3 Likes

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?

3 Likes

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:
https://support.google.com/accounts/answer/185833

5 Likes

Thank you, that’s what I needed!

I have 2FA enabled on my gmail, so I had to create an app-specific password at https://myaccount.google.com/apppasswords and then used that instead of my real password.

2 Likes

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

Hi,

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: https://support.google.com/mail/answer/7126229?visit_id=1-636519273322816733-295827898&hl=en&rd=1#zippy=%2Cstep-check-that-imap-is-turned-on%2Ci-cant-sign-in-to-my-email-client

Under Troubleshooting step 2, theres the one that solved it for me:
https://www.google.com/accounts/DisplayUnlockCaptcha

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

Hope it helps others.
Cheers.

how did you do that?

Thank you for your information :slight_smile:

1 Like