Mail sync failed - Mail server denied authentication

Support intro

The mail app does not load the message body. All mails are listed in the inbox and other mail folders. The email-subject, sender, date received, etc. is fully displayed.
Instead of the message body (content) following error occurs: “Could not load message”
In approx. 1 out of 10 tries, the message is loaded completely.

I have the rainloop app running in nextcloud with the same mail account settings without issues.

The log in the admin section shows following error messages:

[mail] Fehler: OCA\Mail\Exception\ServiceException: Sync failed for 114:INBOX: Mail server denied authentication. at <>

[mail] Warnung: Horde_Imap_Client_Exception: Mail server denied authentication. at <>

Nextcloud version (eg, 20.0.5): 25.0.3
Mail (): 2.2.2
Operating system and version (eg, Ubuntu 20.04): Linux 4.4.180+ x86_64 on Synology DSM7
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.54
PHP version (eg, 7.4): 8.0

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N):
Since 2 weeks it occurs.

Steps to replicate it:

  1. open mail app
  2. click on a mail in the inbox or any other folder of the mailbox

The output of your Nextcloud log in Admin > Logging:

[mail] Fehler: OCA\Mail\Exception\ServiceException: Sync failed for 114:INBOX: Mail server denied authentication. at <<closure>>

0. /volume1/web/nextcloud/apps/mail/lib/Service/Sync/SyncService.php line 126
   OCA\Mail\Service\Sync\ImapToDbSynchronizer->sync(OCA\Mail\Account {}, OCA\Mail\Db\Mailbox {id: 913}, OC\AppFramework\ScopedPsrLogger {}, 42, [1026,1027,1033, ... 8], false)
1. /volume1/web/nextcloud/apps/mail/lib/Controller/MailboxesController.php line 153
   OCA\Mail\Service\Sync\SyncService->syncMailbox(OCA\Mail\Account {}, OCA\Mail\Db\Mailbox {id: 913}, 42, [13695,13381,130 ... 5], true, null)
2. /volume1/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 225
   OCA\Mail\Controller\MailboxesController->sync(913, [13695,13381,130 ... 5], false, null)
3. /volume1/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 133
   OC\AppFramework\Http\Dispatcher->executeController(OCA\Mail\Control ... {}, "sync")
4. /volume1/web/nextcloud/lib/private/AppFramework/App.php line 172
   OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Control ... {}, "sync")
5. /volume1/web/nextcloud/lib/private/Route/Router.php line 298
   OC\AppFramework\App::main("OCA\\Mail\\Cont ... r", "sync", OC\AppFramework\ ... {}, ["913","mail.mailboxes.sync"])
6. /volume1/web/nextcloud/lib/base.php line 1047
   OC\Route\Router->match("/apps/mail/api/mailboxes/913/sync")
7. /volume1/web/nextcloud/index.php line 36
   OC::handleRequest()

POST /index.php/apps/mail/api/mailboxes/913/sync
from 192.168.*.** by xxx at 2023-01-30T19:45:27+00:00


[mail] Warnung: Horde_Imap_Client_Exception: Mail server denied authentication. at <<closure>>

 0. /volume1/web/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php line 850
    Horde_Imap_Client_Socket->_login("*** sensitive parameters replaced ***")
 1. /volume1/web/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php line 2507
    Horde_Imap_Client_Base->login("*** sensitive parameters replaced ***")
 2. /volume1/web/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php line 2490
    Horde_Imap_Client_Base->_fetchWrapper("INBOX", Horde_Imap_Client_Fetch_Query {}, [Horde_Imap_Clie ... }])
 3. /volume1/web/nextcloud/apps/mail/lib/IMAP/MessageMapper.php line 674
    Horde_Imap_Client_Base->fetch("INBOX", Horde_Imap_Client_Fetch_Query {}, [Horde_Imap_Clie ... }])
 4. /volume1/web/nextcloud/apps/mail/lib/IMAP/PreviewEnhancer.php line 86
    OCA\Mail\IMAP\MessageMapper->getBodyStructureData(Horde_Imap_Clien ... e}, "INBOX", [6820,6818,6817,6816])
 5. /volume1/web/nextcloud/apps/mail/lib/Service/Search/MailSearch.php line 133
    OCA\Mail\IMAP\PreviewEnhancer->process(OCA\Mail\Account {}, OCA\Mail\Db\Mailbox {id: 859}, [OCA\Mail\Db\Mes ... }])
 6. /volume1/web/nextcloud/apps/mail/lib/Controller/MessagesController.php line 139
    OCA\Mail\Service\Search\MailSearch->findMessages(OCA\Mail\Account {}, OCA\Mail\Db\Mailbox {id: 859}, null, null, 20)
 7. /volume1/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 225
    OCA\Mail\Controller\MessagesController->index(859, null, null, 20)
 8. /volume1/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 133
    OC\AppFramework\Http\Dispatcher->executeController(OCA\Mail\Controller\MessagesController {}, "index")
 9. /volume1/web/nextcloud/lib/private/AppFramework/App.php line 172
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Controller\MessagesController {}, "index")
10. /volume1/web/nextcloud/lib/private/Route/Router.php line 298
    OC\AppFramework\App::main("OCA\\Mail\\Cont ... r", "index", OC\AppFramework\ ... {}, ["mail.messages.index"])
11. /volume1/web/nextcloud/lib/base.php line 1047
    OC\Route\Router->match("/apps/mail/api/messages")
12. /volume1/web/nextcloud/index.php line 36
    OC::handleRequest()

GET /index.php/apps/mail/api/messages?mailboxId=859&limit=20
from 192.168.*.* by xxx at 2023-01-30T19:45:27+00:00

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '**',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' =>
  array (
    0 => '192.168.*.*',
    1 => '*',
    2 => '*',
    3 => '*',
    4 => '*',
  ),
  'datadirectory' => '/volume1/nextcloud_data',
  'dbtype' => 'mysql',
  'version' => '25.0.3.2',
  'overwrite.cli.url' => 'http://192.168.*.*',
  'dbname' => 'conzel_nc',
  'dbhost' => '127.0.0.1:3307',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '*',
  'dbpassword' => '*',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'loglevel' => 0,
  'log_rotate_size' => 104857600,
  'syslog_tag' => 'Nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '*',
  'mail_domain' => '*',
  'mail_smtphost' => '*',
  'mail_smtpport' => '465',
  'maintenance' => false,
  'has_rebuilt_cache' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '127.0.0.1',
    'port' => 6379,
    'timeout' => 0,
    'password' => '',
    'dbindex' => 0,
  ),
  'theme' => '',
  'app_install_overwrite' =>
  array (
    0 => 'keeweb',
    1 => 'files_texteditor',
    2 => 'pdfdraw',
    3 => 'previewgenerator',
    4 => 'gpxmotion',
    5 => 'richdocuments',
    6 => 'integration_moodle',
    7 => 'openotp_sign',
    8 => 'files_markdown',
    9 => 'jsloader',
    10 => 'gpxedit',
    11 => 'extract',
  ),
  'mail_smtpsecure' => 'ssl',
  'default_phone_region' => 'DE',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '*',
  'mail_smtppassword' => '*',
  'allow_local_remote_servers' => true,
  'app.mail.verify-tls-peer' => false,
);

More logfiles on request.

Your help is highly appreciated. I tried many hours already. Removed the app and did new install, but no success yet.

1 Like

same issue here, did you solve it?

It’s somehow still working, but it’s filling up the log really bad

No. I have no idea what,s wrong. As I wrote in my initial post even a complete new install of the mail app in a propper mail enviroment did not solve the issue.
Also double checked the config according to this manual:

https://nextcloud-mail.readthedocs.io/en/latest/admin/

Currently I’m using rainloop. But the nextcloud integration is not as good with this app.

is the mailbox working or is it completely gone for you?
If it is generally working, activate debugging and check if there might be a timeout while checking the E-Mails! I just changed the timeout from 2 seconds to 20 seconds for imap to check if this is still happening.

The mailbox is generally working, but not usable.
I’ll check it again in debug-mode next week.

Since my last post in February the situation changed altough I didn’t change anything on the system. The error-message “Could not load the message” doesn’t appear anymore when opening a single mail. However it takes extemly long to oben the message-body. Sometimes more than 30 seconds, typically 20 seconds.
Two week ago I updated mail from 2.2.2 to 2.2.5 and Nextcloud to 25.0.5. This changed nothing on the behaviour.
No error occurs in the system-log. I didn’t activate the Debugmode yet as suggested by Autchirion in the previous post. Meanwhile I switched to Snappy mail, which runs normal. The message body opens within 4 seconds or less. This is an indication, that my mail-server is performing normally.

Is this related to the issue described here? Suspicious "Too many auth attempts" · Issue #9156 · nextcloud/mail · GitHub

Or is there another github issue that is relevant here?