Skip to content

Commit 15f9055

Browse files
parshikovWebklex
authored andcommitted
Fix #41 error imap_expunge(): supplied resource is not a valid imap resource (#42)
1 parent e613af1 commit 15f9055

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
66

77
## [UNRELEASED]
88
### Fixed
9-
- NaN
9+
- #41 imap_expunge(): supplied resource is not a valid imap resource
1010

1111
### Added
1212
- NaN

src/IMAP/Client.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ class Client {
8686
*/
8787
protected $activeFolder = false;
8888

89+
/**
90+
* Connected parameter
91+
* @var bool
92+
*/
93+
protected $connected = false;
94+
8995
/**
9096
* Client constructor.
9197
*
@@ -148,7 +154,7 @@ public function setReadOnly($readOnly = true) {
148154
* @return bool
149155
*/
150156
public function isConnected() {
151-
return ($this->connection) ? true : false;
157+
return $this->connected;
152158
}
153159

154160
/**
@@ -191,6 +197,7 @@ public function connect($attempts = 3) {
191197
$attempts,
192198
config('imap.options.open')
193199
);
200+
$this->connected = !! $this->connection;
194201
} catch (\ErrorException $e) {
195202
$errors = imap_errors();
196203
$message = $e->getMessage().'. '.implode("; ", (is_array($errors) ? $errors : array()));
@@ -208,8 +215,7 @@ public function connect($attempts = 3) {
208215
*/
209216
public function disconnect() {
210217
if ($this->isConnected()) {
211-
$this->expunge();
212-
imap_close($this->connection);
218+
$this->connected = ! imap_close($this->connection, CL_EXPUNGE);
213219
}
214220

215221
return $this;
@@ -462,4 +468,4 @@ public function expunge(){
462468
public function checkCurrentMailbox(){
463469
return imap_check($this->connection);
464470
}
465-
}
471+
}

0 commit comments

Comments
 (0)