IMAP Accounts do not connect to NextCloud


I Cannot connect my mail accounts with Nextcloud. According to my logs i am receiving those errors. I checked the email accounts that imap is activated and setup correctly on the mail server. Can someone please provide a tip what i should do in order to connect my email accounts.

I am using SSL/TLS for (Port 993) IMAP and STARTTLS for (PORT 587) SMTP.

[mail] Error: OCA\Mail\Exception\ServiceException: IMAP error: Error connecting to mail server. at <>

  1. /var/www/ line 91
    OCA\Mail\IMAP\MailboxSync->sync(OCA\Mail\Account {}, OC\AppFramework\ScopedPsrLogger {}, true)
  2. /var/www/ line 80
    OCA\Mail\BackgroundJob\SyncJob->run({accountId: 6})
  3. /var/www/ line 61
    OCP\BackgroundJob\Job->execute(OC\BackgroundJob\JobList {}, OC\Log {})
  4. /var/www/ line 127
    OCP\BackgroundJob\TimedJob->execute(OC\BackgroundJob\JobList {}, OC\Log {})

Hello! I use Rainloop instead of the Mail app, but hopefully I can point you in the right direction. :slight_smile:

  • I notice the error messages says mail server at <>. Did you remove the mail server hostname from the log for privacy, or is that what it says?
  • If you haven’t already, testing the exact settings with a different client can often yield more useful error messages.
  • Some providers use SSL/TLS on port 587, as opposed to STARTTLS. Also, some clients will hide this distinction, making it hard to tell which is the right option. I’d verify this with the provider.
  • Your Nextcloud server might not be able to reach the mail server at all for unknown reasons (DNS issues?). If you have SSH access, you might try pinging the mail server from the Nextcloud host - I’d also ping with IPv6 (ping6 command) if that’s enabled.
1 Like

Hello MacTrent.

I tried RainLoop this works like a charme. I could not figure out what the issue was but right now i am way to busy to check this out.

I verified the config files they are all looking good.
i tried to ping the email servers everything worked.
i tried to connect the accounts to kmail | thunderbird | Evolution. Everything worked fine.

I will use RainLoop this is the easiest and quickest solution. Maybe in the next year i have more time to find out what i am doing wrong ( ibet this is just a minor detail that i did wrong, as always) but well the devils lies in the detail.

Thank you for your support.


Most likely. We also have extensive logging of IMAP and SMTP connection once you enable debug mode. This typically points to where the issue lies. You could try that if you have a few minutes.

Hello @ChristophWurst

I tried it again. checked all the settings on nextcloud site and on the email clientside again i can think of.

  • I pinged the mailservers
  • i checked the imap settings on and gmail
  • I checked the gmail setting to allow less secure apps
  • checked the basic config files of the firewall and of nextcloud
  • to answer @mactrent question i did not delete anything from the logs

I still receive the same errors. can someone please point me in a direction to find the error here?

Thank you for your help.

Did you check those?

It is working now but i had to change the config.php in /var/www//config/

I added the line ‘app.mail.transport’ => ‘php-mail’

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.