-
-
Notifications
You must be signed in to change notification settings - Fork 818
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
ImapClient can send commands that are too long #834
Comments
I got a second mailbox wich has the same error. |
I'm betting the problem is that the list of UIDs in your request is too long for the server to process. Try to break apart your If that is the problem, then I might have to look into breaking apart long commands in MailKit. It's something I figured I might have to do, but was hoping to avoid it because it sucks to have to do :-\ The real problem, if you look at your logs, is not so much the number of UIDs, but the number of characters it takes to serialize the UIDs. So, for example, in your first log, the long string of UIDs starts off with |
Ah that makes a lot of sense! |
Cool, thanks. If you are up for playing around a bit, it would be interesting to know what outlook.com's maximum buffer size allowance is for the list of UIDs. If you played around with changing the number of UIDs in your list to vary the length of the serialized list of UIDs to see how large it can be before it fails, that would give us a pretty good idea of what that limitation is. |
Another work-around that you could do long-term is that since your query seems like it includes all of the UIDs in the folder, you could use Just a thought for you going forward. |
I will try to find out the limitations for you 👍 Thats just because this is the initial synchronization |
Ok, gotcha. That makes sense. |
Yep that actually solves the problem! |
Awesome, thanks for playing around with this for me. I really appreciate it :-) |
You are very welcome! |
I've committed a fix for this issue now, but it would be fantastic if you could test it out for me. The nuget version will be 2.1.3.12 on the myget feed linked on the main page of the github repo. |
After testing both mailboxes wich failed i can confirm, that the fix seems to work perfectly! |
Excellent :-) There's an RFC that gives recommendations for client and server implementers to follow and their recommendation was to max command-lines at 1000 characters and servers to support at least up to 8000 characters. My new implementation in MailKit pushes the boundaries a bit (it uses a limit of 8000 characters instead of 1000), but that should be ok and indeed it seems to work for Exchange. Courier IMAP, for example, allows each individual token in the command to be 16k (there's no limit on the command-line, just on the individual tokens). When MailKit encounters Courier, we use the 16k limit. I think UW.IMAP is the only IMAP server in wide use that only allows 1000, so I'm working on a way to detect UW.IMAP and limit MailKit to 1000 characters for that server. Anyway, awesome to hear this is working for you now :-) I was afraid this was going to be a lot more complicated to fix than it was... |
When i try to download headerdata of e-mails for a specific folder via IMAP this error happens:
MailKit.Net.Imap.ImapCommandException: 'The IMAP server replied to the 'FETCH' command with a 'BAD' response: Command Error. 10'
It does not even matter wich MessageSummaryItems i request.
Here is how i do it:
imapFolder.Fetch(uniqueIds, MessageSummaryItems.UniqueId)
Since i saw a few other issues with similar problems i have also created a log via a ProtocolLogger and attached it.
As you can see from the log a lot of folders worked before the error gets thrown for the "Sent" folder.
imap.log
Can you lead me into a direction what exactly does not work here and what i could do to fix it?
additional information about what my code does
my code basicly synchronizes all folders and mails (only header data) to our database since working live with IMAP is rather slow.
This is used for displaying the whole mailbox of a user in our software.
The text was updated successfully, but these errors were encountered: