public function clearFolder($mailbox)
    {
        if ($this->countMessages($mailbox) > 0) {
            $res = $this->flag($mailbox, '1:*', 'DELETED');
        }

        if ($res) {
            if ($this->selected === $mailbox) {
                $res = $this->close();
            }
            else {
                $res = $this->expunge($mailbox);
            }
        }

        return $res;
    }