From 379b4b3deeec01c062862d1fde5ead7556caff4a Mon Sep 17 00:00:00 2001 From: DINH QUOC THANH Date: Sun, 13 Nov 2022 13:03:52 +0700 Subject: [PATCH] KAYAKOC-32013 | oAuth with POP3 does not detect the emails in the mailbox (#2) * bugfix\KAYAKOC-32013 * add function fwrite * update indent --- src/Protocol/Pop3.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Protocol/Pop3.php b/src/Protocol/Pop3.php index dcc9895a..ab20a4a6 100644 --- a/src/Protocol/Pop3.php +++ b/src/Protocol/Pop3.php @@ -8,6 +8,7 @@ namespace Zend\Mail\Protocol; use Zend\Stdlib\ErrorHandler; +use function fwrite; class Pop3 { @@ -138,6 +139,29 @@ public function sendRequest($request) } } + /** + * Send requests + * + * @param string $requests your request in array + * @throws Exception\RuntimeException + */ + public function sendRequests($requests = []) + { + ErrorHandler::start(); + $result = ''; + foreach ($requests as $request) { + if (fwrite($this->socket, $request . "\r\n") === false) { + throw new Exception\RuntimeException('cannot write - connection closed?'); + } + $result = $result.fgets($this->socket)."\r\n"; + } + $error = ErrorHandler::stop(); + if (! $result) { + throw new Exception\RuntimeException('send failed - connection closed?', 0, $error); + } + return $result; + } + /** * read a response *