imap icon indicating copy to clipboard operation
imap copied to clipboard

Is there any support IMAP IDLE?

Open StasToken opened this issue 4 years ago • 4 comments

Actually, the question in the title is whether it is possible to receive mail in real time using IMAP IDLE?

StasToken avatar Jan 07 '21 05:01 StasToken

As far as I know, PHP doesn't provide any idle functionality, does it?

Slamdunk avatar Jan 07 '21 08:01 Slamdunk

Oh, really?

require 'vendor/autoload.php';

$imap = new \Noi\Util\Mail\ImapIdleClient('your.imap.host', 993);
$imap->login('username', 'password');
$imap->selectMailbox('INBOX');

while (!$imap->idle(300) instanceof \PEAR_Error) {
    $mails = $imap->search('UNSEEN');
    foreach ($imap->getMessages($mails) as $mail) {
        echo '==== New Message ====', "\n";
        echo $mail, "\n";
    }
}

I found this in another package, but I wonder if you have it :)

StasToken avatar Jan 07 '21 09:01 StasToken

That sounds like a sleep call, easy to implement by yourself

Slamdunk avatar Jan 07 '21 10:01 Slamdunk

Oh, really?

require 'vendor/autoload.php';

$imap = new \Noi\Util\Mail\ImapIdleClient('your.imap.host', 993);
$imap->login('username', 'password');
$imap->selectMailbox('INBOX');

while (!$imap->idle(300) instanceof \PEAR_Error) {
    $mails = $imap->search('UNSEEN');
    foreach ($imap->getMessages($mails) as $mail) {
        echo '==== New Message ====', "\n";
        echo $mail, "\n";
    }
}

I found this in another package, but I wonder if you have it :)

hello you can use the search method from 163 email?

thesky2017 avatar Jan 29 '21 08:01 thesky2017