Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMAP FETCH Bug #377

Open
Uni2K opened this issue Mar 10, 2021 · 2 comments
Open

IMAP FETCH Bug #377

Uni2K opened this issue Mar 10, 2021 · 2 comments
Assignees
Labels

Comments

@Uni2K
Copy link

Uni2K commented Mar 10, 2021

Hello,
its me again :D

I just found a new bug, here you can see a picture of it:
bug

It was recorded in TB and shows that the numbers of unseen messages changes randomly. Moreover, also the total number of messages are displayed incorrectly, despite Greenmail holding the correct number of messages in the folder.
The bug can be seen most dominant in Thunderbird but also in Outlook (it just does not show some messages).

The good news is that I already found the solution: The UIDs need to be sorted while returning the FETCH response to the client.

Example:

Wrong:

  • 1 FETCH (FLAGS (\Seen ) UID 1)
  • 4 FETCH (FLAGS (\Seen ) UID 2)
  • 3 FETCH (FLAGS (\Seen ) UID 3)
  • 2 FETCH (FLAGS (\Seen ) UID 4)

Correct:

  • 1 FETCH (FLAGS (\Seen ) UID 1)
  • 2 FETCH (FLAGS (\Seen ) UID 2)
  • 3 FETCH (FLAGS (\Seen ) UID 3)
  • 4 FETCH (FLAGS (\Seen ) UID 4)

So, all you have to do is to change the getMessageUids() method in the folder implementations to sort the uids before returning:
something like:

  @Override
    public long[] getMessageUids() {
        long[] uids=mailMessages.getMessageUids();
        Arrays.sort(uids);
        return uids;
    }

And then everything will work fine :)

@marcelmay marcelmay self-assigned this Mar 10, 2021
@marcelmay marcelmay added the bug label Mar 10, 2021
@marcelmay marcelmay added this to the 1.6.3 milestone Mar 10, 2021
@marcelmay
Copy link
Member

Thx again for the detailed analysis!

@marcelmay
Copy link
Member

@Uni2K , the GreenMail internal implementation holding messages is a list so the order should be the same. I also tried to reproduce using Thunderbird (mailbox with couple of messages 'unseen' and refreshing).

Can you provide the GreenMail verbose (eg via -Dgreenmail.verbose) output including the IMAP commands?
Which client are you using?

@marcelmay marcelmay modified the milestones: 1.6.3, 1.6.4 Mar 28, 2021
@marcelmay marcelmay removed this from the 1.6.4 milestone May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants