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

Unexpected token in IMAP response: '[' #115

Closed
marspd opened this issue Oct 24, 2014 · 15 comments
Closed

Unexpected token in IMAP response: '[' #115

marspd opened this issue Oct 24, 2014 · 15 comments

Comments

@marspd
Copy link

marspd commented Oct 24, 2014

Hi there
I'm using Mailkit (from nuget) with an Office365 account and when I try to use the MoveTo method I get the error above. The mail item does get moved successfully.

I'm getting around this at the moment with the copy/delete option.

Excellent code by the way, saved me a whole heap of bother. :-)

capture

@jstedfast
Copy link
Owner

In the ImapClient .ctor, you can pass a ProtocolLogger to log the protocol traffic to a stream (or to a text file). Could you do that and paste the "MOVE" command client & server chatter?

@marspd
Copy link
Author

marspd commented Oct 24, 2014

I was moving an e-mail from the Inbox to a subfolder under the Inbox called 'Invalid', here is the log

S: A00000010 OK FETCH completed.
C: A00000011 UID MOVE 31 INBOX/Invalid
S: [COPYUID 55 31 6]
S: * 1 EXPUNGE
S: * 0 EXISTS
S: A00000011 OK MOVE completed.

@jstedfast
Copy link
Owner

Ugh... Microsoft, read the specifications >_<

The problem is the [COPYUID ...] line which does not follow the specification at all :-\

An example (from the specification) of what that should look like:

   C: a UID MOVE 42:69 foo
   S: * OK [COPYUID 432432 42:69 1202:1229]
   S: * 22 EXPUNGE
   S: (more expunges)
   S: a OK Done

Basically, the [COPYUID ...] line should be preceded by * OK.

@jstedfast
Copy link
Owner

The above commit should fix this issue, but I don't have an Office365 account to test against.

If you could let me know if that fixes it, that would be helpful. Thanks!

@marspd
Copy link
Author

marspd commented Oct 25, 2014

Microsoft? Standards? Come on, get real. :-) Thanks for the quick fix. I will let you know when I have had a chance to test it. Will this change make it into the nuget package anytime soon or do I need to download the version for github?

@jstedfast
Copy link
Owner

No problem. I was hoping to have the fix confirmed before making a release to NuGet to avoid having to make another release if my fix doesn't work.

@jstedfast
Copy link
Owner

I've uploaded 1.0.1 to NuGet. I'm fairly sure my commit will fix this.

@marspd
Copy link
Author

marspd commented Oct 27, 2014

I've tested it and it works fine. Thanks for the excellent code and the quick turnaround.

weltmeyer pushed a commit to weltmeyer/MailKit that referenced this issue Nov 13, 2014
@weltmeyer
Copy link

Update:
Created new issue #121

I got a similar Problem with outlook.com IMAP Account:

S: F00000018 OK [READ-ONLY] EXAMINE completed.
C: F00000019 NOOP
S: F00000019 OK NOOP completed
C: F00000020 UID FETCH 100001:100010 (UID FLAGS BODY.PEEK[HEADER.FIELDS (AD-HOC APPARENTLY-TO APPROVED ARTICLE BCC BYTES CC COMMENTS CONTENT-BASE CONTENT-CLASS CONTENT-DESCRIPTION CONTENT-DISPOSITION CONTENT-DURATION CONTENT-ID CONTENT-LANGUAGE CONTENT-LENGTH CONTENT-LOCATION CONTENT-MD5 CONTENT-TRANSFER-ENCODING CONTENT-TYPE CONTROL DATE DEFERRED-DELIVERY DISPOSITION-NOTIFICATION-TO DISTRIBUTION DKIM-SIGNATURE DOMAINKEY-SIGNATURE ENCODING ENCRYPTED EXPIRES EXPIRY-DATE FOLLOWUP-TO FROM IMPORTANCE IN-REPLY-TO KEYWORDS LINES LIST-HELP LIST-SUBSCRIBE LIST-UNSUBSCRIBE MESSAGE-ID MIME-VERSION NEWSGROUPS NNTP-POSTING-HOST ORGANIZATION PATH PRECEDENCE PRIORITY RECEIVED REFERENCES REPLY-BY REPLY-TO RESENT-BCC RESENT-CC RESENT-DATE RESENT-FROM RESENT-MESSAGE-ID RESENT-REPLY-TO RESENT-SENDER RESENT-TO RETURN-PATH RETURN-RECEIPT-TO SENDER SENSITIVITY STATUS SUBJECT SUMMARY SUPERSEDES TO USER-AGENT X-MAILER X-MSMAIL-PRIORITY X-PRIORITY X-STATUS UNKNOWN)])
S: * 1 FETCH (UID 100001 FLAGS (\Seen) BODY[HEADER.FIELDS ("AD-HOC" "APPARENTLY-TO" "APPROVED" "ARTICLE" "BCC" "BYTES" "CC" "COMMENTS" "CONTENT-BASE" "CONTENT-CLASS" "CONTENT-DESCRIPTION" "CONTENT-DISPOSITION" "CONTENT-DURATION" "CONTENT-ID" "CONTENT-LANGUAGE" "CONTENT-LENGTH" "CONTENT-LOCATION" "CONTENT-MD5" "CONTENT-TRANSFER-ENCODING" "CONTENT-TYPE" "CONTROL" "DATE" "DEFERRED-DELIVERY" "DISPOSITION-NOTIFICATION-TO" "DISTRIBUTION" "DKIM-SIGNATURE" "DOMAINKEY-SIGNATURE" "ENCODING" "ENCRYPTED" "EXPIRES" "EXPIRY-DATE" "FOLLOWUP-TO" "FROM" "IMPORTANCE" "IN-REPLY-TO" "KEYWORDS" "LINES" "LIST-HELP" "LIST-SUBSCRIBE" "LIST-UNSUBSCRIBE" "MESSAGE-ID" "MIME-VERSION" "NEWSGROUPS" "NNTP-POSTING-HOST" "ORGANIZATION" "PATH" "PRECEDENCE" "PRIORITY" "RECEIVED" "REFERENCES" "REPLY-BY" "REPLY-TO" "RESENT-BCC" "RESENT-CC" "RESENT-DATE" "RESENT-FROM" "RESENT-MESSAGE-ID" "RESENT-REPLY-TO" "RESENT-SENDER" "RESENT-TO" "RETURN-PATH" "RETURN-RECEIPT-TO" "SENDER" "SENSITIVITY" "STATUS" "SUBJECT" "SUMMARY" "SUPERSEDES" "TO" "USER-AGENT" "X-MAILER" "X-MSMAIL-PRIORITY" "X-PRIORITY" "X-STATUS" "UNKNOWN")] {284}

Getting Exception:
Unexpected token in IMAP response: [qstring: "AD-HOC"]
image

@gluszczek
Copy link

gluszczek commented Jul 7, 2017

Unexpected COPYUID in IMAP response using folder.MoveTo()

I've also got a similar problem. I'am using MailKit 1.16.0.0.
Trying to move a message from Inbox to another folder with home.pl account. The message is moved but it throws an exception and disconnect.
I've tested with gmail.com account and there is no problem.

In result: ImapProtocolException: 'Syntax error in response. Unexpected token: [atom: COPYUID]'.
Here are logs from gmail.com and home.pl:

moveerror

@jstedfast
Copy link
Owner

Hi @gluszczek

The problem is that the COPYUID response code needs to appear in the OK response line like it does in gmail. It looks like home.pl has a bug in its implementation.

@gluszczek
Copy link

Thanks for your reply. Is there any walk around this bug?

@jstedfast
Copy link
Owner

I think the work-around that I just committed should work.

@gluszczek
Copy link

I just tested it and your commit fixed this issue. Thanks!

@jstedfast
Copy link
Owner

you're welcome!

jstedfast added a commit that referenced this issue Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants