Mail can't connect to a dovecot imap server

Hi.

I am having problems connecting the mail client to a dovecot imap server. Thunderbird connects to the server fine. I can connect to other imap servers like a cyrus server no problems.

On the mail server connection page I get a “Request failed with status code 500”

On the mail server I see this in the log:

Feb 21 07:44:09 oi-mail1 dovecot: imap-login: Login: user=<XXXXX>, method=PLAIN, rip=192.168.0.153, lip=192.168.0.153, mpid=11744, TLS, session=<hgt85BefSMPAqACZ>
Feb 21 07:44:09 oi-mail1 postfix/submission/smtpd[11745]: connect from XXXXXX[192.168.0.153]
Feb 21 07:44:10 oi-mail1 postfix/submission/smtpd[11745]: disconnect from XXXX[192.168.0.153] ehlo=2 starttls=1 auth=1 quit=1 commands=5
Feb 21 07:44:10 oi-mail1 dovecot: imap(XXXXX)<11744><hgt85BefSMPAqACZ>: Logged out in=8 out=457 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Feb 21 07:44:10 oi-mail1 dovecot: imap-login: Login: user=<XXXXX>, method=PLAIN, rip=192.168.0.153, lip=192.168.0.153, mpid=11748, TLS, session=<NoJ+5BefUMPAqACZ>
Feb 21 07:44:10 oi-mail1 dovecot: imap(XXXXXXX)<11748><NoJ+5BefUMPAqACZ>: Logged out in=291 out=1226 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0

Any thoughts?
thanks,
Geoff

Here is the debug log from nextcloud.

{“reqId”:“eTLh3kl6EbBdGDdeGt3i”,“level”:1,“time”:“February 21, 2020 16:44:10”,“remoteAddr”:“192.168.0.149”,“user”:“XXXX”,“app”:“mail”,“method”:“POST”,“url”:"/index.php/apps/mail/api/accounts",“message”:“Setting up manually configured account”,“userAgent”:“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0”,“version”:“18.0.1.3”}

{“reqId”:“eTLh3kl6EbBdGDdeGt3i”,“level”:0,“time”:“February 21, 2020 16:44:10”,“remoteAddr”:“192.168.0.149”,“user”:“XXXX”,“app”:“mail”,“method”:“POST”,“url”:"/index.php/apps/mail/api/accounts",“message”:“Connecting to account XXXX”,“userAgent”:“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0”,“version”:“18.0.1.3”}

{“reqId”:“eTLh3kl6EbBdGDdeGt3i”,“level”:0,“time”:“February 21, 2020 16:44:10”,“remoteAddr”:“192.168.0.149”,“user”:“XXXX”,“app”:“mail”,“method”:“POST”,“url”:"/index.php/apps/mail/api/accounts",“message”:“account created 11”,“userAgent”:“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0”,“version”:“18.0.1.3”}

{"reqId":"asDaFuGBm1xNb37aUDPH","level":3,"time":"February 21, 2020 16:44:10","remoteAddr":"192.168.0.149","user":"XXXX","app":"mail","method":"GET","url":"/index.php/apps/mail/api/accounts/11/folders","message":
{“Exception”:“Horde_Imap_Client_Exception_ServerResponse",“Message”:“IMAP error reported by server.”,“Code”:0,"Trace”:[{“file”:"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php",“line”:4314,“function”:"_getLine",“class”:“Horde_Imap_Client_Socket”,“type”:"->",“args”:[{“data”:{“modseqs”:[],“modseqs_nouid”:[]},“fetch”:
{“class”:“Horde_Imap_Client_Fetch_Results”},“class”:“Horde_Imap_Client_Interaction_Pipeline”}]},{“file”:"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php",“line”:4242,“function”:"_sendCmdChunk",“class”:“Horde_Imap_Client_Socket”,“type”:"->",“args”:[{“data”:{“modseqs”:[],“modseqs_nouid”:[]},“fetch”:
{“class”:“Horde_Imap_Client_Fetch_Results”},“class”:“Horde_Imap_Client_Interaction_Pipeline”},[{“debug”:[],“literalplus”:true,“literal8”:false,“on_error”:null,“on_success”:null,“pipeline”:{“data”:{“modseqs”:[],“modseqs_nouid”:[]},“fetch”:
{“class”:“Horde_Imap_Client_Fetch_Results”},“class”:“Horde_Imap_Client_Interaction_Pipeline”},“response”:{“tag”:“7”,“responseCode”:{“data”:
[],“code”:“CANNOT”,“class”:“stdClass”},“status”:3,“token”:{“class”:“Horde_Imap_Client_Tokenize”},“class”:“Horde_Imap_Client_Interaction_Server_Tagged”},“tag”:“7”,“class”:“Horde_Imap_Client_Interaction_Command”}]]},{“file”:"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php",“line”:1751,“function”:"_sendCmd",“class”:“Horde_Imap_Client_Socket”,“type”:"->",“args”:[{“data”:{“modseqs”:[],“modseqs_nouid”:[]},“fetch”:
{“class”:“Horde_Imap_Client_Fetch_Results”},“class”:“Horde_Imap_Client_Interaction_Pipeline”}]},{“file”:"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php",“line”:1733,“function”:"_status",“class”:“Horde_Imap_Client_Socket”,“type”:"->",“args”:[[{“class”:“Horde_Imap_Client_Mailbox”}],8205]},{“file”:"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php",“line”:4038,“function”:“status”,“class”:“Horde_Imap_Client_Base”,“type”:"->",“args”:[[“virtual/Flagged”],8205]},{“file”:"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php",“line”:3590,“function”:"_syncStatus",“class”:“Horde_Imap_Client_Base”,“type”:"->",“args”:[“virtual/Flagged”]},{“file”:"/var/www/nextcloud/apps/mail/lib/IMAP/FolderMapper.php",“line”:80,“function”:“getSyncToken”,“class”:“Horde_Imap_Client_Base”,“type”:"->",“args”:[“virtual/Flagged”]},{“file”:"/var/www/nextcloud/apps/mail/lib/IMAP/MailboxSync.php",“line”:77,“function”:“getFolders”,“class”:“OCA\Mail\IMAP\FolderMapper”,“type”:"->",“args”:[{“class”:“OCA\Mail\Account”},{“cacheFields”:{“9”:“HICenv”,“10”:“HICflags”,“8”:“HIChdrs”,“11”:“HICdate”,“12”:“HICsize”,“1”:“HICstruct”},“changed”:true,“statuscache”:true,“class”:“Horde_Imap_Client_Socket”}]},{“file”:"/var/www/nextcloud/apps/mail/lib/Service/MailManager.php",“line”:93,“function”:“sync”,“class”:“OCA\Mail\IMAP\MailboxSync”,“type”:"->",“args”:[{“class”:“OCA\Mail\Account”}]},{“file”:"/var/www/nextcloud/apps/mail/lib/Controller/FoldersController.php",“line”:76,“function”:“getFolders”,“class”:“OCA\Mail\Service\MailManager”,“type”:"->",“args”:[{“class”:“OCA\Mail\Account”}]},{“file”:"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",“line”:170,“function”:“index”,“class”:“OCA\Mail\Controller\FoldersController”,“type”:"->",“args”:[11]},{“file”:"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",“line”:99,“function”:“executeController”,“class”:“OC\AppFramework\Http\Dispatcher”,“type”:"->",“args”:[{“class”:“OCA\Mail\Controller\FoldersController”},“index”]},{“file”:"/var/www/nextcloud/lib/private/AppFramework/App.php",“line”:125,“function”:“dispatch”,“class”:“OC\AppFramework\Http\Dispatcher”,“type”:"->",“args”:[{“class”:“OCA\Mail\Controller\FoldersController”},“index”]},{“file”:"/var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php",“line”:47,“function”:“main”,“class”:“OC\AppFramework\App”,“type”:"::",“args”:[“OCA\Mail\Controller\FoldersController”,“index”,{“class”:“OC\AppFramework\DependencyInjection\DIContainer”},{“accountId”:“11”,"_route":“mail.folders.index”}]},{“function”:"__invoke",“class”:“OC\AppFramework\Routing\RouteActionHandler”,“type”:"->",“args”:[{“accountId”:“11”,"_route":“mail.folders.index”}]},{“file”:"/var/www/nextcloud/lib/private/Route/Router.php",“line”:299,“function”:“call_user_func”,“args”:[{“class”:“OC\AppFramework\Routing\RouteActionHandler”},{“accountId”:“11”,"_route":“mail.folders.index”}]},{“file”:"/var/www/nextcloud/lib/base.php",“line”:1008,“function”:“match”,“class”:“OC\Route\Router”,“type”:"->",“args”:["/apps/mail/api/accounts/11/folders"]},{“file”:"/var/www/nextcloud/index.php",“line”:38,“function”:“handleRequest”,“class”:“OC”,“type”:"::",“args”:[]}],“File”:"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php",“Line”:4602,“CustomMessage”:"–"},“userAgent”:“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0”,“version”:“18.0.1.3”}

The dovecot installation I had configured had a folder called virtual/Flagged

I removed that folder and now it works fine.