Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,21 @@ public function isConnected(): bool {
* @throws ResponseException
*/
public function checkConnection(): bool {
$active_folder = $this->active_folder;
try {
if (!$this->isConnected()) {
$this->connect();
if ($active_folder !== null) {
$this->openFolder($active_folder, true);
}
return true;
}
} catch (\Throwable) {
$this->connect();
if ($active_folder !== null) {
$this->openFolder($active_folder, true);
}
return true;
}
return false;
}
Expand Down
11 changes: 10 additions & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function __construct(int $uid, ?int $msglist, Client $client, ?int $fetch
$this->events["message"] = $client->getDefaultEvents("message");
$this->events["flag"] = $client->getDefaultEvents("flag");

$this->folder_path = $client->getFolderPath();
$this->setFolderPath($client->getFolderPath());

$this->setSequence($sequence);
$this->setFetchOption($fetch_options);
Expand Down Expand Up @@ -1470,6 +1470,15 @@ public function getFolderPath(): string {
* @return Message
*/
public function setFolderPath($folder_path): Message {
if (!is_string($folder_path) || $folder_path === '') {
$folder_path = $this->client?->getFolderPath();
}
if (!is_string($folder_path) || $folder_path === '') {
$folder_path = (string)$this->config->get('options.common_folders.inbox', 'INBOX');
}
if ($folder_path === '') {
$folder_path = 'INBOX';
}
$this->folder_path = $folder_path;

return $this;
Expand Down