Skip to content

Commit c760ebe

Browse files
committed
Class destructor added
1 parent 179b7aa commit c760ebe

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/IMAP/Client.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ public function __construct($config = []) {
9595
$this->setConfig($config);
9696
}
9797

98+
/**
99+
* Client destructor
100+
*/
101+
public function __destruct() {
102+
$this->disconnect();
103+
}
104+
98105
/**
99106
* Set the Client configuration
100107
*
@@ -201,6 +208,7 @@ public function connect($attempts = 3) {
201208
*/
202209
public function disconnect() {
203210
if ($this->isConnected()) {
211+
$this->expunge();
204212
imap_close($this->connection);
205213
}
206214

@@ -419,5 +427,4 @@ public function expunge(){
419427
public function checkCurrentMailbox(){
420428
return imap_check($this->connection);
421429
}
422-
423430
}

0 commit comments

Comments
 (0)