Skip to content

Commit b916e4e

Browse files
Update ImapProtocol.php (Webklex#449)
1 parent ed1eb04 commit b916e4e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Connection/Protocols/ImapProtocol.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ public function connect(string $host, int $port = null): bool {
9090
return true;
9191
}
9292

93+
/**
94+
* Check if the current session is connected
95+
*
96+
* @return bool
97+
*/
98+
public function connected(): bool {
99+
if ((bool)$this->stream) {
100+
try {
101+
$this->requestAndResponse('NOOP');
102+
return true;
103+
}
104+
catch (ImapServerErrorException|RuntimeException) {
105+
return false;
106+
}
107+
}
108+
return false;
109+
}
110+
93111
/**
94112
* Enable tls on the current connection
95113
*

0 commit comments

Comments
 (0)