|
14 | 14 | use DirectoryTree\ImapEngine\Connection\Streams\StreamInterface; |
15 | 15 | use DirectoryTree\ImapEngine\Connection\Tokens\Token; |
16 | 16 | use DirectoryTree\ImapEngine\Enums\ImapFetchIdentifier; |
17 | | -use DirectoryTree\ImapEngine\Exceptions\Exception; |
18 | 17 | use DirectoryTree\ImapEngine\Exceptions\ImapCommandException; |
19 | 18 | use DirectoryTree\ImapEngine\Exceptions\ImapConnectionClosedException; |
20 | 19 | use DirectoryTree\ImapEngine\Exceptions\ImapConnectionFailedException; |
21 | 20 | use DirectoryTree\ImapEngine\Exceptions\ImapConnectionTimedOutException; |
22 | 21 | use DirectoryTree\ImapEngine\Exceptions\ImapResponseException; |
23 | 22 | use DirectoryTree\ImapEngine\Exceptions\ImapStreamException; |
24 | 23 | use DirectoryTree\ImapEngine\Support\Str; |
| 24 | +use Exception; |
25 | 25 | use Generator; |
26 | 26 | use LogicException; |
27 | 27 |
|
@@ -69,8 +69,14 @@ public static function fake(array $responses = []): static |
69 | 69 | */ |
70 | 70 | public function __destruct() |
71 | 71 | { |
72 | | - if ($this->connected()) { |
73 | | - $this->logout(); |
| 72 | + if (! $this->connected()) { |
| 73 | + return; |
| 74 | + } |
| 75 | + |
| 76 | + try { |
| 77 | + @$this->logout(); |
| 78 | + } catch (Exception $e) { |
| 79 | + // Do nothing. |
74 | 80 | } |
75 | 81 | } |
76 | 82 |
|
@@ -182,14 +188,7 @@ public function login(string $user, string $password): TaggedResponse |
182 | 188 | */ |
183 | 189 | public function logout(): void |
184 | 190 | { |
185 | | - try { |
186 | | - // It's generally acceptable to send a logout command to an IMAP server |
187 | | - // and not wait for a response. If the server encounters an error |
188 | | - // processing the request, we will have to reconnect anyway. |
189 | | - $this->send('LOGOUT', tag: $tag); |
190 | | - } catch (Exception) { |
191 | | - // Do nothing. |
192 | | - } |
| 191 | + $this->send('LOGOUT', tag: $tag); |
193 | 192 | } |
194 | 193 |
|
195 | 194 | /** |
|
0 commit comments