/** * @param string $sFolderFullNameRaw * @param bool $bUnsubscribeOnDeletion = true * * @return \MailSo\Mail\MailClient * * @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Mail\Exceptions\RuntimeException */ public function FolderDelete($sFolderFullNameRaw, $bUnsubscribeOnDeletion = true) { if (0 === \strlen($sFolderFullNameRaw) || 'INBOX' === $sFolderFullNameRaw) { throw new \MailSo\Base\Exceptions\InvalidArgumentException(); } $this->oImapClient->FolderExamine($sFolderFullNameRaw); $aIndexOrUids = $this->oImapClient->MessageSimpleSearch('ALL'); if (0 < \count($aIndexOrUids)) { throw new \MailSo\Mail\Exceptions\NonEmptyFolder(); } $this->oImapClient->FolderExamine('INBOX'); if ($bUnsubscribeOnDeletion) { $this->oImapClient->FolderUnSubscribe($sFolderFullNameRaw); } $this->oImapClient->FolderDelete($sFolderFullNameRaw); return $this; }