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 *