ezcMailImapTransport::deleteMailbox PHP Method

deleteMailbox() public method

Inbox and the the currently selected mailbox cannot be deleted. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully.
public deleteMailbox ( string $mailbox ) : boolean
$mailbox string
return boolean
    public function deleteMailbox($mailbox)
    {
        if ($this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY) {
            throw new ezcMailTransportException("Can't call deleteMailbox() when not successfully logged in.");
        }
        if (strtolower($this->selectedMailbox) == strtolower($mailbox)) {
            throw new ezcMailTransportException("Can't delete the currently selected mailbox.");
        }
        $tag = $this->getNextTag();
        $this->connection->sendData("{$tag} DELETE \"{$mailbox}\"");
        $response = trim($this->getResponse($tag));
        if ($this->responseType($response) != self::RESPONSE_OK) {
            throw new ezcMailTransportException("The IMAP server could not delete the mailbox '{$mailbox}': {$response}.");
        }
        return true;
    }

Usage Example

コード例 #1
0
 public function testUidDelete()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port, array('uidReferencing' => true));
     $imap->authenticate(self::$user, self::$password);
     $imap->createMailbox("Guybrush");
     $imap->selectMailbox('inbox');
     $imap->copyMessages(self::$ids[0], "Guybrush");
     $imap->selectMailbox("Guybrush");
     $imap->delete(1);
     $imap->selectMailbox('inbox');
     $imap->deleteMailbox("Guybrush");
 }
All Usage Examples Of ezcMailImapTransport::deleteMailbox