(PHP3 , PHP4 )
imap_createmailbox -- Create a new mailbox
Description
int imap_createmailbox
(int imap_stream, string mbox)
imap_createmailbox() creates a new mailbox
specified by mbox. Names containing
international characters should be encoded by imap_utf7_encode()
Returns true on success and false on error.
See also imap_renamemailbox(),
imap_deletemailbox() and
imap_open() for the format
of mbox names.
Példa 1. imap_createmailbox() example 1
2 $mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
3 || die("can't connect: ".imap_last_error());
4
5 $name1 = "phpnewbox";
6 $name2 = imap_utf7_encode("phpnewböx");
7
8 $newname = $name1;
9
10 echo "Newname will be '$name1'<br>\n";
11
12 # we will now create a new mailbox "phptestbox" in your inbox folder,
13 # check its status after creation and finaly remove it to restore
14 # your inbox to its initial state
15 if(@imap_createmailbox($mbox,imap_utf7_encode("{your.imap.host}INBOX.$newname"))) {
16 $status = @imap_status($mbox,"{your.imap.host}INBOX.$newname",SA_ALL);
17 if($status) {
18 print("your new mailbox '$name1' has the following status:<br>\n");
19 print("Messages: ". $status->messages )."<br>\n";
20 print("Recent: ". $status->recent )."<br>\n";
21 print("Unseen: ". $status->unseen )."<br>\n";
22 print("UIDnext: ". $status->uidnext )."<br>\n";
23 print("UIDvalidity:". $status->uidvalidity)."<br>\n";
24
25 if(imap_renamemailbox($mbox,"{your.imap.host}INBOX.$newname","{your.imap.host}INBOX.$name2")) {
26 echo "renamed new mailbox from '$name1' to '$name2'<br>\n";
27 $newname=$name2;
28 } else {
29 print "imap_renamemailbox on new mailbox failed: ".imap_last_error()."<br>\n";
30 }
31 } else {
32 print "imap_status on new mailbox failed: ".imap_last_error()."<br>\n";
33 }
34 if(@imap_deletemailbox($mbox,"{your.imap.host}INBOX.$newname")) {
35 print "new mailbox removed to restore initial state<br>\n";
36 } else {
37 print "imap_deletemailbox on new mailbox failed: ".implode("<br>\n",imap_errors())."<br>\n";
38 }
39
40 } else {
41 print "could not create new mailbox: ".implode("<br>\n",imap_errors())."<br>\n";
42 }
43
44 imap_close($mbox);
45 |
|