Skip to content

Commit f049aca

Browse files
committed
Delete folder method added
1 parent 440417f commit f049aca

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Client.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,34 @@ public function createFolder(string $folder_path, bool $expunge = true): Folder
688688
return $folder;
689689
}
690690

691+
/**
692+
* Delete a given folder
693+
* @param string $folder_path
694+
* @param boolean $expunge
695+
*
696+
* @return array
697+
* @throws AuthFailedException
698+
* @throws ConnectionFailedException
699+
* @throws EventNotFoundException
700+
* @throws FolderFetchingException
701+
* @throws ImapBadRequestException
702+
* @throws ImapServerErrorException
703+
* @throws RuntimeException
704+
* @throws ResponseException
705+
*/
706+
public function deleteFolder(string $folder_path, bool $expunge = true): array {
707+
$this->checkConnection();
708+
709+
$folder = $this->getFolderByPath($folder_path);
710+
$status = $this->getConnection()->deleteFolder($folder_path)->validatedData();
711+
if ($expunge) $this->expunge();
712+
713+
$event = $this->getEvent("folder", "deleted");
714+
$event::dispatch($folder);
715+
716+
return $status;
717+
}
718+
691719
/**
692720
* Check a given folder
693721
* @param string $folder_path

0 commit comments

Comments
 (0)