diff --git a/src/IMAP/Client.php b/src/IMAP/Client.php index b550ec0..e1813f6 100644 --- a/src/IMAP/Client.php +++ b/src/IMAP/Client.php @@ -89,10 +89,18 @@ class Client { /** * Connected parameter + * * @var bool */ protected $connected = false; + /** + * IMAP errors that might have ben occurred + * + * @var array $errors + */ + protected $errors = []; + /** * Client constructor. * @@ -216,6 +224,7 @@ public function connect($attempts = 3) { */ public function disconnect() { if ($this->isConnected()) { + $this->errors = array_merge($this->errors, imap_errors() ?: []); $this->connected = ! imap_close($this->connection, CL_EXPUNGE); } @@ -451,7 +460,9 @@ public function getAlerts(){ * @return array */ public function getErrors(){ - return imap_errors(); + $this->errors = array_merge($this->errors, imap_errors() ?: []); + + return $this->errors; } /**