-
- Notifications
You must be signed in to change notification settings - Fork 183
Description
Describe the bug
Hi @Webklex,
I am trying to use the IDLE function of IMAP. Folder provides the method idle(callback, ...). Unfortunately the method always gives me the error message "unique id not found".
I took a closer look at the method and found out that the value EXISTS is evaluated. If I interpret the specification of IMAP correctly, then EXISTS tells how many e-mails are in the respective folder. However, in the idle method, the number of emails (EXISTS) is used as UID to find out the new email. In my mailbox, the number is not equal to the UID and thus no email is found.
Folder also has a getStatus() method that returns the next UID by "uidnext". I tried to find my new email with this UID, but also without success.
Am I doing something wrong or did I not understand something correctly?
Used config
Please provide the used config, if you are not using the package default config.
I use the default configuration
Code to Reproduce
The troubling code section which produces the reported bug.
/** @var Folder $inbox */ $inbox = $client->getFolderByName("INBOX"); $inbox->idle(function (Message $message) { $text = sprintf("%s: %s", $message->getUid(), $message->getSubject()); var_dump($text); }, 1200, false);Desktop / Server (please complete the following information):
- OS: [Mac OS Big Sur]
- PHP: [8.0.14]
- Version [3.1.0-alpha]
- Provider [Gmail]
Additional context
Here is my modified idle method:
while (true) { try { $line = $connection->nextLine(); $connection->done(); $status = $this->getStatus(); echo $status["uidnext"]; $this->client->openFolder($this->path, true); $message = $this->query()->getMessageByMsgn($status["uidnext"]); $message->setSequence($sequence); $callback($message); $event = $this->getEvent("message", "new"); $event::dispatch($message); $connection->idle(); }catch (Exceptions\RuntimeException $e) { // ... } }Maybe the method should also check if IDLE is available from the IMAP server. I have added this check:
if (!in_array("IDLE", $connection->getCapabilities())) { throw new Exceptions\RuntimeException("IMAP server does not support IDLE"); }