NextCloud Mail Stops Syncing After Initial Emails

Hi NextCloud Community,

I’ve set up my mail account in NextCloud Mail using the following configuration:

Initially, my mailbox syncs correctly, and I can see my emails. However, after the first few emails load, the sync stops, and no new emails are downloaded. I’ve checked my mail server settings, and everything seems to be configured properly.

Has anyone encountered this issue before? Is there a known fix or a recommended way to properly configure NextCloud Mail with iCloud’s mail servers?

Any help would be greatly appreciated!

Thanks in advance!

No idea and since you didn’t fill out the support template we can only speculate.

You may find the Nextcloud Mail Admin Documentation - Troubleshooting section helpful to diagnose what is going on.

Ok thank you….ill fill out thanks

I’m getting the same issue.

The Basics

Summary of the issue you are facing:

After initial setup of icloud on the nextcloud email client new messages will not download. I can see that there are emails unread but cannot view them. Other email accounts (GMX, Gmail) appear uneffected

Steps to replicate it (hint: details matter!):

Setup icloud email (I’m using app passwords) with recommended settings. Wait until new messages start coming in and synchronization breaks, roughly 24 hours in my case.

Log entries

These errors show on repeat:

[mail] Error: Sync failed for 1:INBOX: IMAP error reported by server.
	POST /apps/mail/api/mailboxes/11/sync
	from 165.1.251.174 by aaron at Feb 27, 2025, 10:07:27 AM

[PHP] Error: iconv(): Detected an illegal character in input string at /var/www/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43
	from ? by ? at Feb 27, 2025, 10:04:26 AM

[PHP] Error: fread(): SSL: Connection reset by peer at /var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket/Connection/Socket.php#190
	from ? by ? at Feb 27, 2025, 10:02:56 AM

[mail] Error: Cron mail sync failed for account 1
	from ? by ? at Feb 27, 2025, 9:30:11 AM

one of the mail sync entries:

{"reqId":"VduZ6B44SjjcFvKGGFhh","level":3,"time":"2025-02-27T09:30:11-08:00","remoteAddr":"","user":false,"app":"mail","method":"","url":"--","message":"Cron mail sync failed for account 1","userAgent":"--","version":"31.0.0.18","exception":{"Exception":"OCA\\Mail\\Exception\\ServiceException","Message":"Sync failed for 1:INBOX: IMAP error reported by server.","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":133,"function":"sync","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/SyncJob.php","line":93,"function":"syncAccount","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":61,"function":"run","class":"OCA\\Mail\\BackgroundJob\\SyncJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":88,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":75,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":168,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","Line":282,"Previous":{"Exception":"Horde_Imap_Client_Exception_ServerResponse","Message":"IMAP error reported by server.","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php","line":4319,"function":"_getLine","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php","line":4243,"function":"_sendCmdChunk","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php","line":2478,"function":"_sendCmd","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php","line":2282,"function":"_search","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php","line":3542,"function":"search","class":"Horde_Imap_Client_Base","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Data/Sync.php","line":229,"function":"resolveIds","class":"Horde_Imap_Client_Base","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php","line":3643,"function":"__construct","class":"Horde_Imap_Client_Data_Sync","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/IMAP/Sync/Synchronizer.php","line":99,"function":"sync","class":"Horde_Imap_Client_Base","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/IMAP/Sync/Synchronizer.php","line":69,"function":"doCombinedSync","class":"OCA\\Mail\\IMAP\\Sync\\Synchronizer","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":401,"function":"sync","class":"OCA\\Mail\\IMAP\\Sync\\Synchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":263,"function":"runPartialSync","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":133,"function":"sync","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/SyncJob.php","line":93,"function":"syncAccount","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":61,"function":"run","class":"OCA\\Mail\\BackgroundJob\\SyncJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":88,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":75,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":168,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php","Line":4620},"message":"Cron mail sync failed for account {accountId}","exception":[],"CustomMessage":"Cron mail sync failed for account 1"},"id":"67c0ab628a9d1"}

and the mail sync cron entry

{"reqId":"hnGTEtI5ZEHodObqR9M5","level":3,"time":"2025-02-27T08:25:12-08:00","remoteAddr":"","user":false,"app":"mail","method":"","url":"--","message":"Cron mail sync failed for account 1","userAgent":"--","version":"31.0.0.18","exception":{"Exception":"OCA\\Mail\\Exception\\ServiceException","Message":"Sync failed for 1:INBOX: IMAP error reported by server.","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":133,"function":"sync","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/SyncJob.php","line":93,"function":"syncAccount","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":61,"function":"run","class":"OCA\\Mail\\BackgroundJob\\SyncJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":88,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":75,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":168,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","Line":282,"Previous":{"Exception":"Horde_Imap_Client_Exception_ServerResponse","Message":"IMAP error reported by server.","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php","line":4319,"function":"_getLine","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php","line":4243,"function":"_sendCmdChunk","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php","line":2478,"function":"_sendCmd","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php","line":2282,"function":"_search","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php","line":3542,"function":"search","class":"Horde_Imap_Client_Base","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Data/Sync.php","line":229,"function":"resolveIds","class":"Horde_Imap_Client_Base","type":"->"},{"file":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php","line":3643,"function":"__construct","class":"Horde_Imap_Client_Data_Sync","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/IMAP/Sync/Synchronizer.php","line":99,"function":"sync","class":"Horde_Imap_Client_Base","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/IMAP/Sync/Synchronizer.php","line":69,"function":"doCombinedSync","class":"OCA\\Mail\\IMAP\\Sync\\Synchronizer","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":401,"function":"sync","class":"OCA\\Mail\\IMAP\\Sync\\Synchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":263,"function":"runPartialSync","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->"},{"file":"/var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php","line":133,"function":"sync","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/mail/lib/BackgroundJob/SyncJob.php","line":93,"function":"syncAccount","class":"OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":61,"function":"run","class":"OCA\\Mail\\BackgroundJob\\SyncJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":88,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":75,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":168,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php","Line":4620},"message":"Cron mail sync failed for account {accountId}","exception":[],"CustomMessage":"Cron mail sync failed for account 1"},"id":"67c0ab628abc9"}

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

I genuinely don’t know where or how to find this.

Apps

The output of occ app:list (if possible).

occ command doesn’t work on my install, but I’ve installed only office and mail apps.

Ehcorn, thank you for responding, unfortunately for me I don’t have all the skills most of the people here have. I purchased an Asustor NAS and NextCloud was one of the apps that came with. My goal was to set up an identical iCloud system that I use on my Mac platform from my iPhone iPad, Mac’s. I was looking for a turnkey system so that I could help some of my clients were in the medical community set up their own internal iCloud system to protect the patient information. But there doesn’t seem to be too many options like iCloud, Or similar to Nextcloud. If anyone on this board knows of any software that can run on a Asustor NAS or any other NAS Please let me know that’s turn key. For the issue with the emails if you know of a step-by-step process on how to fill out the Nextcloud prompts so that the email works please let me know. Thank u