1--TEST--
2Test imap_createmailbox() function : basic functionality
3--SKIPIF--
4<?php
5require_once(dirname(__FILE__).'/skipif.inc');
6?>
7--FILE--
8<?php
9/* Prototype  : bool imap_createmailbox  ( resource $imap_stream  , string $mailbox  )
10 * Description: Creates a new mailbox specified by mailbox .
11 * Source code: ext/imap/php_imap.c
12 */
13
14echo "*** Testing imap_createmailbox() : basic functionality ***\n";
15
16require_once(dirname(__FILE__).'/imap_include.inc');
17
18$imap_stream = imap_open($default_mailbox, $username, $password) or
19	die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
20
21$newname = "phpnewbox";
22
23echo "Newname will be '$newname'\n";
24
25$newbox = imap_utf7_encode($server.$newname);
26if (imap_createmailbox($imap_stream, $newbox)) {
27
28	echo "Add a couple of msgs to '$newname' mailbox\n";
29	populate_mailbox($imap_stream, $newbox, 2);
30
31    $status = imap_status($imap_stream, $newbox, SA_ALL);
32    if ($status) {
33        echo "Your new mailbox '$newname' has the following status:\n";
34        echo "Messages:    " . $status->messages    . "\n";
35        echo "Recent:      " . $status->recent      . "\n";
36        echo "Unseen:      " . $status->unseen      . "\n";
37        echo "UIDnext:     " . $status->uidnext     . "\n";
38        echo "UIDvalidity: " . $status->uidvalidity . "\n";
39
40    } else {
41        echo "imap_status on new mailbox failed: " . imap_last_error() . "\n";
42    }
43
44    if (imap_deletemailbox($imap_stream, $newbox)) {
45        echo "Mailbox '$newname' removed to restore initial state\n";
46    } else {
47        echo "imap_deletemailbox on new mailbox failed: " . implode("\n", imap_errors()) . "\n";
48    }
49
50} else {
51    echo "could not create new mailbox: " . implode("\n", imap_errors()) . "\n";
52}
53
54imap_close($imap_stream);
55
56?>
57===Done===
58--EXPECTF--
59*** Testing imap_createmailbox() : basic functionality ***
60Newname will be 'phpnewbox'
61Add a couple of msgs to 'phpnewbox' mailbox
62Your new mailbox 'phpnewbox' has the following status:
63Messages:    2
64Recent:      2
65Unseen:      2
66UIDnext:     %d
67UIDvalidity: %d
68Mailbox 'phpnewbox' removed to restore initial state
69===Done===
70