From d31171b912e0f88585c0343ffb3a969e7644e630 Mon Sep 17 00:00:00 2001 From: Max Korlaar Date: Tue, 3 Mar 2026 15:13:22 +0900 Subject: [PATCH 1/2] Add $idling property to prevent NOOP command from being sent in IDLE mode --- src/Connection/Protocols/ImapProtocol.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Connection/Protocols/ImapProtocol.php b/src/Connection/Protocols/ImapProtocol.php index 6871d57f..20810382 100644 --- a/src/Connection/Protocols/ImapProtocol.php +++ b/src/Connection/Protocols/ImapProtocol.php @@ -41,6 +41,12 @@ class ImapProtocol extends Protocol { */ protected int $noun = 0; + /** + * Whether the connection is currently in IDLE mode + * @var bool + */ + protected bool $idling = false; + /** * Imap constructor. * @param Config $config @@ -102,6 +108,10 @@ public function connect(string $host, ?int $port = null): bool { */ public function connected(): bool { if ((bool)$this->stream) { + if ($this->idling) { + return true; + } + try { $this->requestAndResponse('NOOP'); return true; @@ -185,7 +195,7 @@ protected function assumedNextLineIgnoreUntagged(Response $response, string $sta protected function nextTaggedLine(Response $response, ?string &$tag): string { $line = $this->nextLine($response); if (str_contains($line, ' ')) { - list($tag, $line) = explode(' ', $line, 2); + [$tag, $line] = explode(' ', $line, 2); } return $line ?? ''; @@ -205,7 +215,7 @@ protected function nextTaggedLineIgnoreUntagged(Response $response, &$tag): stri $line = $this->nextLine($response); } while ($this->isUntaggedLine($line)); - list($tag, $line) = explode(' ', $line, 2); + [$tag, $line] = explode(' ', $line, 2); return $line; } @@ -1372,6 +1382,7 @@ public function idle(): void { if (!$this->assumedNextLineIgnoreUntagged($response, '+ ')) { throw new RuntimeException('idle failed'); } + $this->idling = true; } /** @@ -1384,6 +1395,7 @@ public function done(): bool { if (!$this->assumedNextTaggedLineIgnoreUntagged($response, 'OK', $tags)) { throw new RuntimeException('done failed'); } + $this->idling = false; return true; } @@ -1426,7 +1438,7 @@ public function search(array $params, int|string $uid = IMAP::ST_UID): Response */ public function overview(string $sequence, int|string $uid = IMAP::ST_UID): Response { $result = []; - list($from, $to) = explode(":", $sequence); + [$from, $to] = explode(":", $sequence); $response = $this->getUid(); $ids = []; From f1d0736fd1ab598cc4dffd8e5b9d7af5925c11be Mon Sep 17 00:00:00 2001 From: Max Korlaar Date: Tue, 3 Mar 2026 15:16:13 +0900 Subject: [PATCH 2/2] Fix typos in composer.json and README.md --- README.md | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fa6cd7a1..9b67ce09 100755 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ if you're just wishing a feature ;) ## Alternatives & Different Flavors -This library and especially the code flavor It's written in, is certainly not for everyone. If you are looking for a +This library and especially the code flavor it's written in, is certainly not for everyone. If you are looking for a different approach, you might want to check out the following libraries: - [ddeboer/imap](https://github.com/ddeboer/imap) - [barbushin/php-imap](https://github.com/barbushin/php-imap) diff --git a/composer.json b/composer.json index 334275fa..ddb1a367 100644 --- a/composer.json +++ b/composer.json @@ -35,8 +35,8 @@ "phpunit/phpunit": "^9.5.10" }, "suggest": { - "symfony/mime": "Recomended for better extension support", - "symfony/var-dumper": "Usefull tool for debugging" + "symfony/mime": "Recommended for better extension support", + "symfony/var-dumper": "Useful tool for debugging" }, "autoload": { "psr-4": {