diff --git a/src/Fetch/Server.php b/src/Fetch/Server.php index a4cf684..aa1da30 100644 --- a/src/Fetch/Server.php +++ b/src/Fetch/Server.php @@ -485,4 +485,16 @@ class Server { return imap_list($this->getImapStream(), $this->getServerSpecification(), $pattern); } + + /** + * Deletes the given mailbox. + * + * @param $mailbox + * + * @return bool + */ + public function deleteMailBox($mailbox) + { + return imap_deletemailbox($this->getImapStream(), $this->getServerSpecification() . $mailbox); + } } diff --git a/tests/Fetch/Test/ServerTest.php b/tests/Fetch/Test/ServerTest.php index d9875a6..553f002 100644 --- a/tests/Fetch/Test/ServerTest.php +++ b/tests/Fetch/Test/ServerTest.php @@ -183,6 +183,14 @@ class ServerTest extends \PHPUnit_Framework_TestCase $this->assertTrue($server->hasMailBox('Cheese'), 'Mailbox "Cheese" was created'); } + public function testDeleteMailbox() + { + $server = static::getServer(); + $this->assertTrue($server->hasMailBox('Cheese'), 'Does have mailbox "Cheese"'); + $this->assertTrue($server->deleteMailBox('Cheese'), 'deleteMailBox returns true.'); + $this->assertFalse($server->hasMailBox('Cheese'), 'Mailbox "Cheese" was deleted'); + } + /** * @expectedException \RuntimeException */