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

Message "11964" does not exist: imap_fetchstructure(): Bad message number #310

Closed
JosefRypacek opened this issue Mar 9, 2018 · 6 comments
Labels

Comments

@JosefRypacek
Copy link

Hi,
I've updated (from some very old version) to current and now I'm getting Ddeboer\Imap\Exception\MessageDoesNotExistException. My code isn't complicated and I got this exception only few times (not sure when). Am I doing something wrong?
Thanks

Stack trace is probably:

Foreach
  Ddeboer\Imap\MessageIterator->current()
    Ddeboer\Imap\Message->__construct(...)
      Ddeboer\Imap\Message->loadStructure(...)

My code:

$mailbox = $connection->getMailbox('INBOX');
$messages = $mailbox->getMessages();
foreach ($messages as $message) {
...
}
@Slamdunk
Copy link
Collaborator

Slamdunk commented Mar 9, 2018

Hi, I think this may happen only if:

  1. You retrieve the current message list
  2. You start the foreach loop
  3. The server moves one of the messages not yet iterated
  4. The foreach loop gets to the moved message

Did you try to manually retrieve the 11964 id to see if it's still there?

@Slamdunk Slamdunk added the bug label Mar 9, 2018
@JosefRypacek
Copy link
Author

Yes, you are probably right, but...
Is there any change from 0.5.2 (I know, a lot of changes) which can cause this problem?
I don't know how to use try-catch to skip the missing message and continue with other messages. Maybe this should be handled by iterator itself?

@Slamdunk
Copy link
Collaborator

Slamdunk commented Mar 9, 2018

I'm working on making this more graceful. In the meantime you can wrap the MessageIterator into another OuterIterator that uses a try/catch with a filter iterator to strip out those errors and keep the loop going.

@JosefRypacek
Copy link
Author

OK, thank you. I've already created temporary solution for this case.

This is really good library for IMAP. :)

@Slamdunk
Copy link
Collaborator

With #320 now the exception is thrown inside a foreach loop, so you can use the try/catch without the loop beeing halted.

@Slamdunk
Copy link
Collaborator

Released in 1.4.0

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