We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
imap_ping()
1 parent 13bdfa9 commit 9857a1dCopy full SHA for 9857a1d
src/PhpImap/Mailbox.php
@@ -476,7 +476,17 @@ public function getImapStream(bool $forceConnection = true)
476
477
public function hasImapStream(): bool
478
{
479
- return (\is_resource($this->imapStream) || $this->imapStream instanceof \IMAP\Connection) && \imap_ping($this->imapStream);
+ try {
480
+ return (\is_resource($this->imapStream) || $this->imapStream instanceof \IMAP\Connection) && \imap_ping($this->imapStream);
481
+ } catch (\Error $exception) {
482
+ // From PHP 8.1.10 imap_ping() on a closed stream throws a ValueError. See #680.
483
+ $valueError = '\ValueError';
484
+ if (class_exists($valueError) && $exception instanceof $valueError) {
485
+ return false;
486
+ }
487
+
488
+ throw $exception;
489
490
}
491
492
/**
0 commit comments