question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IMAP doesn't sync correctly - BAD 'Command Error' following APPEND

See original GitHub issue

Expected behavior

After setting up an IMAP account in K9 mail I’m having perfect 2-way synchronisation with a Desktop mail client application. Everything I do (read, delete) in either application reflects in the other. I would have expected that it stays this way.

Actual behavior

After using it for some month perfectly this way, suddenly about 2 weeks ago I got syncing errors and they do not go away. Issues observed:

  1. When I read a mail in K9, it is marked as such. But after the next sync, it is marked as unread again. Older messages from before the issue (older than 2 weeks when it started happening) stay marked as read (as they should). It seems the ‘read’ mail status is not propagated.

  2. When I delete a mail in K9, I do not see it anymore in the list, even after a new sync as expected. But if then goto the Desktop mail client, the deleted messages still appear. It seems the deleted messages in K9 are not deleted from the Server. This used to work perfectly.

Steps to reproduce

For the ‘read mail’ issue:

  1. Read an unread mail in K9 -> it is marked as such
  2. Sync mail again -> the mail is marked as unread again
  3. Steps 1 and 2 can be repeated…

For the ‘delete mail’ issue:

  1. Delete a mail from K9 -> it is removed from the mail list
  2. Sync mail again -> it does not re-appear again (good)
  3. Sync mail in Desktop mail client -> deleted mail still appears

Environment

K-9 Mail version: Latest 5.010

Android version: 6.0.1 on Rooted Samsung GT-N7100

Account type (IMAP, POP3, WebDAV/Exchange): IMAP

Attached Logs

I have attached 5 logs (filtered from logcat using ‘k9’ Regex) in chronological order

  1. Read Mail.txt -> Read 1 mail on account ‘Henk @ Primestream’
  2. Sync Mail.txt -> Sync mail directly after that (log might show traces of multiple IMAP account)
  3. Sync Mail (Warning Level).txt -> Same as above, but filtered for ‘Warning Level’ messages
  4. Delete Mail.txt -> Delete one mail from account ‘Henk @ Primestream’
  5. Sync Mail.txt -> Sync mail directly after that

1. Read Mail.txt 2. Sync Mail.txt 3. Sync Mail (Warning Level).txt 4. Delete Mail.txt 5. Sync Mail.txt

Errors I see in logs

Looking at the logs, I see at least the following when Syncing mail:

com.fsck.k9.mail.MessagingException: Could not find UID for message based on Message-ID
Caused by: java.io.IOException: readStringUntil(): end of stream reached

Might it be that the issues start happening when there are too many items in a mail folder: I was experiencing the problems during a holiday, when the number of items in the Inbox folder exceeded a few hundred (now it is around 300). Normally I keep the Inbox ‘clean’ (around 50 messages or so).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
HenkDempercommented, Jan 5, 2018

For what it is worth: since I originally reported this issue I have not encountered it since. I have switched to Android 7.1 though if that could be of influence…

0reactions
HenkDempercommented, Apr 1, 2020

And to add from the original issuer of this ticket:

  • I don’t think (but can not tell for sure) that I normally have (or had) mails with ultra-long lines (1000 or even 30.000 chars), but then again can’t be 100% sure
  • I have been using K9 mail ever since and always auto-updated to the latest version. I have not experienced the raised problem since a long time, so I consider it fixed in ‘some’ (5.700 or other) version

Thanks for everybody contributing to K9, great work !

Read more comments on GitHub >

github_iconTop Results From Across the Web

IMAP doesn't sync correctly - BAD 'Command Error' following ...
I have been having similar problems appending mail to an Office365 Business (Hosted Exchange) IMAP server (I'm not using your project, rather ...
Read more >
Troubleshoot errors when connecting an inbox with IMAP and ...
Learn more about what happens when you connect your inbox with IMAP and SMTP, and how to resolve any errors you encounter along...
Read more >
Troubleshoot issues with IMAP mailbox migration - Exchange
Troubleshoots issues with migrating a mailbox from an on-premises or third-party IMAP system to Exchange Online.
Read more >
Imap APPEND can't update internal timestamp - Axigen
The imap APPEND command on Axigen can't update internal timestamp of messages and retrivieng message from IMAP is sorted in a bad way....
Read more >
How to Fix Outlook 2019/2016/2013 IMAP Sync Issues? | Stellar
Method 3: Change the Root Folder Path for an IMAP account · Click ?OK? to exit windows and then restart Outlook. · After...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found