diff --git a/src/Connection/Protocols/ImapProtocol.php b/src/Connection/Protocols/ImapProtocol.php index ed1dac6e..6871d57f 100644 --- a/src/Connection/Protocols/ImapProtocol.php +++ b/src/Connection/Protocols/ImapProtocol.php @@ -135,14 +135,10 @@ protected function enableStartTls(): void { * @throws RuntimeException */ public function nextLine(Response $response): string { - $line = ""; - while (($next_char = fread($this->stream, 1)) !== false && !in_array($next_char, ["", "\n"])) { - $line .= $next_char; - } - if ($line === "" && ($next_char === false || $next_char === "")) { + $line = fgets($this->stream); + if ($line === false || $line === '') { throw new RuntimeException('empty response'); } - $line .= "\n"; $response->addResponse($line); if ($this->debug) echo "<< " . $line; return $line;