K-9 does not retrieve mail

Hi, since 2 days K-9 (6.603) on android (12) stopped retrieving emails from our server (after years of usage). I can neither manually nor automatically see them. They are not accessible via individual or unified inbox. I did not install any new apps recently, nor did I change account or other K-9 settings. Fetching the emails via thunderbird on PC (win 10) works as usual. Restarting K-9 as well as the phone did not help. Does anyone have an idea of what might go wrong.

Not without more details, like which email provider/server and if there’s an error message.
Chances are your email provider changed something about login, so details matter.

Thanks for the ligh-speed reply! Our university uses communigate pro. Unfortunately, there is no error message on K-9, the emails simply don’t show up after the ‘update’ arrow stops spinning. I can login to the web interface of the server as usual, no change to the pwd or so. Is there a way to log the fetch procedure?

strangely, K-9 does load the sent and junk folders from the server

I found the logging section for the message fetching and these messages:
first K-9 correctly finds the emails that have not been downloaded, so it can access the server and the inbox, then, many lines down, comes this:

01-26 20:23:04.343  8298  8382 D ImapSync: SYNC: Have 54 unsynced messages
01-26 20:23:04.343  8298  8382 D ImapSync: SYNC: About to fetch 54 unsynced messages for folder INBOX

… some more lines without any indication of a problem that I can see… then:

01-26 20:23:04.387  8298  8382 E ImapSync: Failed synchronizing folder IMTEK:INBOX @ Fri Jan 26 20:23:04 GMT+01:00 2024
01-26 20:23:04.387  8298  8382 I MessagingController:  Command 'syncINBOX' completed

then a few more inconspicuous MessagingController lines and no more errors/failures.

Welcome @uegert :wave:

Unfortunately the lines you’ve omitted with the comment “some more lines without any indication of a problem that I can see” are the ones that contain more information about the error. Please include them here.

PS: You can format the log lines in this forum by selecting the text and pressing CTRL+E (or using the </> button in the toolbar).

1 Like

Hi cketti, here’s the section again, with private information replaced by xxxxxxxx. Thanks for the hint on formatting.

01-26 20:23:04.343  8298  8382 D ImapSync: SYNC: Have 54 unsynced messages
01-26 20:23:04.343  8298  8382 D ImapSync: SYNC: About to fetch 54 unsynced messages for folder INBOX
01-26 20:23:04.344  8298  8382 V RealImapConnection: conn177890135>>> 19 UID FETCH 244093,244092,244091,244090,244089,244088,244087,244085,244084,244080,244079,244078,244077,244076,244075,244074,244072,244071,244069,244066,244065,244064,244062,244061,244060,244059,244057,244056,244055,244051,244049,244048,244047,244045,244044,244042,244041,244040,244039,244038,244037,244036,244035,244025,244021,244020,244019,244018,244017,244016,244014,244012,244008,244005 (UID FLAGS INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER.FIELDS (date subject from content-type to cc bcc reply-to message-id references in-reply-to list-unsubscribe sender X-K9mail-Identity Chat-Version)])
01-26 20:23:04.381  8298  8382 V RealImapConnection: conn177890135<<<#null# [5526, FETCH, [UID, 244005, FLAGS, [\Seen, NonJunk, [EXTERN]], INTERNALDATE, 25-Jan-2024 07:18:15 +0000, RFC822.SIZE, 71570, BODY, [HEADER.FIELDS, [date, subject, from, content-type, to, cc, bcc, reply-to, message-id, references, in-reply-to, list-unsubscribe, sender, X-K9mail-Identity, Chat-Version]], Date: Thu, 25 Jan 2024 08:17:42 +0100 (CET)
01-26 20:23:04.381  8298  8382 V RealImapConnection: From: xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection: Sender: xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection: Reply-To: xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection: To: xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection: Message-ID: xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection: Subject: =xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection:  =xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection:  =xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection:  =xxxxxxxxxxxxxxxxxxxxxxx
01-26 20:23:04.381  8298  8382 V RealImapConnection: Content-Type: text/html; charset="UTF-8"
01-26 20:23:04.381  8298  8382 V RealImapConnection: 
01-26 20:23:04.381  8298  8382 V RealImapConnection: ]]
01-26 20:23:04.382  8298  8382 E ImapSync: synchronizeMailbox
01-26 20:23:04.382  8298  8382 E ImapSync: java.lang.ClassCastException: com.fsck.k9.mail.store.imap.ImapList cannot be cast to java.lang.String
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.mail.store.imap.ImapList.getString(ImapList.java:38)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.mail.store.imap.RealImapFolder.handleFetchResponse(RealImapFolder.kt:711)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.mail.store.imap.RealImapFolder.fetch(RealImapFolder.kt:602)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.backend.imap.ImapSync.fetchUnsyncedMessages(ImapSync.kt:458)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.backend.imap.ImapSync.downloadMessages(ImapSync.kt:328)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.backend.imap.ImapSync.synchronizeMailboxSynchronous(ImapSync.kt:200)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.backend.imap.ImapSync.sync(ImapSync.kt:34)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.backend.imap.ImapBackend.sync(ImapBackend.kt:54)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController.syncFolder(MessagingController.java:616)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController.synchronizeMailboxSynchronous(MessagingController.java:556)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController.synchronizeFolderInBackground(MessagingController.java:2351)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController.lambda$synchronizeFolder$28(MessagingController.java:2323)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController.$r8$lambda$aDvPuf3fqQD52MZIdwGXU2EFGXE(MessagingController.java:0)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController$$ExternalSyntheticLambda31.run(R8$$SyntheticClass:0)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController.runInBackground(MessagingController.java:216)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController.-$$Nest$mrunInBackground(MessagingController.java:0)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at com.fsck.k9.controller.MessagingController$1.run(MessagingController.java:157)
01-26 20:23:04.382  8298  8382 E ImapSync: 	at java.lang.Thread.run(Thread.java:920)
01-26 20:23:04.387  8298  8382 E ImapSync: Failed synchronizing folder IMTEK:INBOX @ Fri Jan 26 20:23:04 GMT+01:00 2024

ok, I got it to work again. I used thunderbird on my PC to delete mails from this sender (which have worked plenty before), empty trash and compact the folders, activated K-9 fetching - worked. Unfortunately I do not know which of these steps was the critical one.

From the log we can see the message that crashed the sync code has an IMAP keyword named [EXTERN]. However, it looks like this name is not allowed (flag-keyword may not contain the ] character).

At the same time there’s a bug in K-9 Mail’s IMAP response parser that treats too many instances of [ as the start of a list. The same bug could be triggered by using a keyword of [something (which I think is a legal value for flag-keyword).

I created an issue for this in our bug tracker: Sync fails when FETCH response contains an IMAP keyword containing `[` · Issue #7589 · thunderbird/thunderbird-android · GitHub

You might want to contact your email provider and tell them to check their server code. The relevant specification is RFC 3501, the relevant rule in the formal grammar is flag-keyword.

Hi, thank you for the feedback. This [EXTERN] flag has indeed appeared only recently in the subject of all emails coming from addresses outside our domain and I do not know why that changed. I’ll check with our IT people. However, […] has long been used with other flags for certain emails within our domain, apparently without problems for K-9.

Many businesses started to introduce these tags in order to fight impersonation attacks. That’s a subset of phishing.

That’s the reason why it was introduced by our IT dept.