You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Idle connection is established successfully with a callback for the new email, but when sending an email to that connected email from another email and being successfully added to the INBOX folder but callback was not fired.
Code to Reproduce
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Webklex\PHPIMAP\ClientManager;
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use Webklex\PHPIMAP\Exceptions\FolderFetchingException;
use Webklex\PHPIMAP\Message;
class ImapIdleTest extends Command
{
protected $signature = 'imap:test-idle';
protected $description = 'Test raw IMAP IDLE using Webklex/php-imap directly';
public function handle()
{
$this->info("🔄 Connecting to Gmail via IMAP...");
$clientManager = new ClientManager();
$client = $clientManager->make([
'host' => 'imap.gmail.com',
'port' => 993,
'encryption' => 'ssl', // or 'tls' if using 587
'validate_cert' => true,
'username' => '[email protected]',
'password' => 'App password', // App Password, not Gmail password
'protocol' => 'imap'
]);
try {
$client->connect();
$this->info("✅ Connected.");
} catch (ConnectionFailedException $e) {
$this->error("❌ Connection failed: " . $e->getMessage());
return 1;
}
try {
$folder = $client->getFolder('INBOX');
} catch (FolderFetchingException $e) {
$this->error("❌ Folder error: " . $e->getMessage());
return 1;
}
$this->info("📨 Listening for new messages via IDLE...");
try {
$folder->idle(function (Message $message) {
echo "\n📥 New message: " . $message->getSubject() . "\n";
});
} catch (ConnectionFailedException $e) {
$this->error("❌ IDLE failed: " . $e->getMessage());
}
}
}
Expected behavior
What is expected is when a new email is received in the INBOX, it would echo in the terminal "📥 New message: " with the subject of the new email.
Desktop / Server:
OS: MacOS 15.3.1 (24D70)
PHP: 8.3.16
Gmail
Additional context
I also tried idling manually to the gmail imap servers using openssl s_client -connect imap.gmail.com:993 -crlf. After that, I logged in using a LOGIN [email protected] "my app password" which would give you success message. using a SELECT INBOX to select inbox and then a IDLE to open an idle connection. When sending a new email, it would print a number that I guess is the number of unread emails.
The text was updated successfully, but these errors were encountered:
Describe the bug
Idle connection is established successfully with a callback for the new email, but when sending an email to that connected email from another email and being successfully added to the
INBOX
folder but callback was not fired.Code to Reproduce
Expected behavior
What is expected is when a new email is received in the INBOX, it would echo in the terminal "📥 New message: " with the subject of the new email.
Desktop / Server:
Additional context
I also tried idling manually to the gmail imap servers using
openssl s_client -connect imap.gmail.com:993 -crlf
. After that, I logged in usinga LOGIN [email protected] "my app password"
which would give you success message. usinga SELECT INBOX
to select inbox and thena IDLE
to open an idle connection. When sending a new email, it would print a number that I guess is the number of unread emails.The text was updated successfully, but these errors were encountered: