Skip to content

imap_msgno returns 0, Unknown: IMAP protocol error: Error in IMAP command COPY: Invalid messageset (0.001 + 0.000 secs). #1177

@jabcreations

Description

@jabcreations

I've been working on Mail / IMAP synchronization with remote servers of late. I managed to move several messages from the inbox to the archive folder (with a shim to compensate for things like Archive and INBOX.Archive). I confirmed that the messages were successfully moved locally and on the remote servers (across multiple different providers, not including Gmail because they don't have a system Archive folder).

Because any developer worth their grain in salt tests-to-verify to the point of hating cake I simply decided to move the messages back from the Archives folder to the Inbox. I received the following errors:

Unknown: IMAP protocol error: Error in IMAP command COPY: Invalid messageset (0.001 + 0.000 secs). (errflg=2)

Unknown: Error in IMAP command COPY: Invalid messageset (0.001 + 0.000 secs). (errflg=2)

Now naturally it doesn't make sense to have multiple ids to identify items though I didn't design any of this. I have the actual unique ids (fully verified) however imap_mail_move uses some sort of fluff "id" that needs to be acquired via imap_msgno. This worked fine the first time however failed the second.

The behavior that I have seemed to confirm is that imap_msgno only seems to work for messages in the inbox, not other folders. I don't know what the underlying cause of this is, just that once a message has left the inbox I can no longer get it's fluff "id".

I have also went to the provider and manually move the same message back to the inbox and then tried using imap_msgno again and it still returns 0. So once a given message has been moved from the inbox I have lost total control to synchronize moving the message any more. I should mention that although obviously implied that yes, I am using imap_expunge($mail_connection); (I'm used to people making stupid comments on my posts in general).

I was using 8.0.3, updated to 8.0.13 and then to 8.1.0, all of which failed. I came across this thread on Stack and then discovered PHP to be using the Microsoft owned Github for some reason with a lock down on PHP's bug report system...for some reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions