ezcMailImapTransport::createMailbox PHP Method

createMailbox() public method

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

Usage Example

コード例 #1
0
 public function testImapMessageSourceEmptySet()
 {
     $transport = new ezcMailImapTransport("mta1.ez.no");
     $transport->authenticate("*****@*****.**", "ezcomponents");
     $transport->createMailbox("Guybrush");
     $transport->selectMailbox("Guybrush");
     $parser = new ezcMailParser();
     $set = new ezcMailStorageSet($transport->fetchAll(), $this->tempDir);
     $mail = $parser->parseMail($set);
     $this->assertEquals(array(), $mail);
     $transport->selectMailbox("Inbox");
     $transport->deleteMailbox("Guybrush");
 }
All Usage Examples Of ezcMailImapTransport::createMailbox