-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
idle function not returning any message when new mail comes #258
Comments
Hi @syedajmal1998 , It turns out the idle connection timeout / lifetime depends on the server settings and might just last for several minutes before it terminates. The I also improved the Its currently running for about 2,5h (applied timeout: 300sec) without any issues. Best regards, |
thank you so much for your time I'll wait |
Hi @syedajmal1998 , Please update to the latest release: https://github.com/Webklex/php-imap/releases/tag/4.0.0 Best regards & happy coding, |
thank you so much for time it means alot, but also can you please update webklex/laravel-imap dependencies, i cant install it |
You are right, its long overdue. Best regards, |
sorry for asking, but its still the same for me. |
also a new bug: Illegal offset type at vendor\webklex\php-imap\src\Connection\Protocols\ImapProtocol.php:646 1 vendor\webklex\php-imap\src\Connection\Protocols\ImapProtocol.php:697 2 \webklex\php-imap\src\Query\Query.php:228 when: $client->getFolder("INBOX")->messages()->all()->limit(5)->get() |
Please enable the The debug output should look something like this, during the "startup" process:
You could also try to reduce the |
<< TAG1 OK AUTHENTICATE completed.
|
here is the full one << * OK The Microsoft Exchange IMAP4 service is ready. [some long code]
|
That looks exactly as expected. Now send an email to that mailbox and check the debug output. You should see something. Please let me know what happens next :) |
i sent multiple messages but no response no new log |
But you did start the idle command before sending the messages correct? Which folder are you idling on? Is it "INBOX" or another folder? If you check the mailbox with another client, where are the new messages located? Inside "INBOX" or another folder? You might also have to wait a little bit until the server has processed the mail and decides to notify all active sessions. |
yes i started idle command before sending new mails and waited and in outlook new mails were in inbox folder |
Another thought: |
i think it worked but got this message
Webklex\PHPIMAP\Exceptions\RuntimeException idle failed at vendor\webklex\php-imap\src\Connection\Protocols\ImapProtocol.php:1043 1 vendor\webklex\php-imap\src\Folder.php:401 2 app\Console\Commands\FetchIdleCommand.php:250
|
That's indeed interesting!
Btw you have Best regards & thanks for helping me understand this "feature", |
'uid_cache' was not in config |
these are all new, Microsoft dropped support for logging in using username & password for imap and everything was working fine till 3-4 days ago. |
I hacked together an alternative idle function, which doesn't check if the /** @var \Webklex\PHPIMAP\Client $client */
$client->connect();
/** @var \Webklex\PHPIMAP\Folder $folder */
$folder = $client->getFolder("INBOX");
$timeout = 300;
$callback = function($message){
dump("New message received: ".$message->subject);
};
/**
* @param \Webklex\PHPIMAP\Connection\Protocols\ProtocolInterface $connection
* @return void
*/
function idle($connection) {
$connection->sendRequest("IDLE");
}
$client->setTimeout($timeout);
if (!in_array("IDLE", $client->getConnection()->getCapabilities())) {
throw new NotSupportedCapabilityException("IMAP server does not support IDLE");
}
$client->openFolder($folder->path, true);
$connection = $client->getConnection();
idle($connection);
$sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN);
while (true) {
try {
$line = $connection->nextLine();
if (($pos = strpos($line, "EXISTS")) !== false) {
$connection->done();
$msgn = (int) substr($line, 2, $pos -2);
$client->openFolder($folder->path, true);
$message = $folder->query()->getMessageByMsgn($msgn);
$message->setSequence($sequence);
$callback($message);
$event = $folder->getEvent("message", "new");
$event::dispatch($message);
idle($connection);
}
}catch (\Webklex\PHPIMAP\Exceptions\RuntimeException $e) {
if(strpos($e->getMessage(), "empty response") >= 0 && $connection->connected()) {
$connection->done();
idle($connection);
continue;
}
if(strpos($e->getMessage(), "connection closed") === false) {
throw $e;
}
$client->reconnect();
$client->openFolder($folder->path, true);
$connection = $client->getConnection();
idle($connection);
}
} In this snipped I could see Best regards, |
thank you so much this worked pretty well. also i set timeout to 20s bcs it waits till timeout ends for new mail to fetch not like before |
that block of code worked and fixed my issue, if this is fixed in package you can close this issue |
and sorry if i said or did something wrong this was my first ever issued a bug in github :) |
Hi @syedajmal1998 , At the moment I would like to wait a little bit to see if this "feature" gets fixed by outlook / Microsoft or if other providers behave the same. I don't think they intended it to work this way. Also removing the "idle" check in general isn't great. So for now I wont modify the idle methods. However you can use the snipped from above to build your own custom idle implementation. I hope you're having a great weekend :) Best regards, |
Please update to v5.1 and give it another try. Best regards, |
Hello Weblex |
Hi @repo-dev-1 , Best regards & happy coding, |
idle function not returning any message when new mail comes
Config:
custom command:
but when i get messages manually it works
The text was updated successfully, but these errors were encountered: