📄 function.imap-getmailboxes.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Read the list of mailboxes, returning detailed information on each one</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imap-getacl.html">imap_getacl</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imap-getsubscribed.html">imap_getsubscribed</a></div> <div class="up"><a href="ref.imap.html">IMAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.imap-getmailboxes" class="refentry"> <div class="refnamediv"> <h1 class="refname">imap_getmailboxes</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">imap_getmailboxes</span> — <span class="dc-title">Read the list of mailboxes, returning detailed information on each one</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>imap_getmailboxes</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$imap_stream</tt></span> , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$ref</tt></span> , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$pattern</tt></span> )</div> <p class="para rdfs-comment"> Gets information on the mailboxes. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt><span class="term"><i><tt class="parameter">imap_stream</tt></i></span><dd><p class="para">An IMAP stream returned by <a href="function.imap-open.html" class="function">imap_open()</a>.</p></dd></dt> <dt> <span class="term"><i><tt class="parameter">ref</tt></i></span> <dd> <p class="para"> <i><tt class="parameter">ref</tt></i> should normally be just the server specification as described in <a href="function.imap-open.html" class="function">imap_open()</a> </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">pattern</tt></i></span> <dd> <p class="para"> Specifies where in the mailbox hierarchy to start searching. </p> <p class="para"> There are two special characters you can pass as part of the <i><tt class="parameter">pattern</tt></i>: '*' and '%'. '*' means to return all mailboxes. If you pass <i><tt class="parameter">pattern</tt></i> as '*', you will get a list of the entire mailbox hierarchy. '%' means to return the current level only. '%' as the <i><tt class="parameter">pattern</tt></i> parameter will return only the top level mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an array of objects containing mailbox information. Each object has the attributes <i><tt class="parameter">name</tt></i>, specifying the full name of the mailbox; <i><tt class="parameter">delimiter</tt></i>, which is the hierarchy delimiter for the part of the hierarchy this mailbox is in; and <i><tt class="parameter">attributes</tt></i>. <i><tt class="parameter">Attributes</tt></i> is a bitmask that can be tested against: <ul class="itemizedlist"> <li class="listitem"> <p class="para"> <b><tt>LATT_NOINFERIORS</tt></b> - This mailbox contains, and may not contain any "children" (there are no mailboxes below this one). Calling <a href="function.imap-createmailbox.html" class="function">imap_createmailbox()</a> will not work on this mailbox. </p> </li> <li class="listitem"> <p class="para"> <b><tt>LATT_NOSELECT</tt></b> - This is only a container, not a mailbox - you cannot open it. </p> </li> <li class="listitem"> <p class="para"> <b><tt>LATT_MARKED</tt></b> - This mailbox is marked. This means that it may contain new messages since the last time it was checked. Not provided by all IMAP servers. </p> </li> <li class="listitem"> <p class="para"> <b><tt>LATT_UNMARKED</tt></b> - This mailbox is not marked, does not contain new messages. If either MARKED or UNMARKED is provided, you can assume the IMAP server supports this feature for this mailbox. </p> </li> </ul> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>imap_getmailboxes()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$mbox </span><span style="color: #007700">= </span><span style="color: #0000BB">imap_open</span><span style="color: #007700">(</span><span style="color: #DD0000">"{imap.example.org}"</span><span style="color: #007700">, </span><span style="color: #DD0000">"username"</span><span style="color: #007700">, </span><span style="color: #DD0000">"password"</span><span style="color: #007700">, </span><span style="color: #0000BB">OP_HALFOPEN</span><span style="color: #007700">)<br /> or die(</span><span style="color: #DD0000">"can't connect: " </span><span style="color: #007700">. </span><span style="color: #0000BB">imap_last_error</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$list </span><span style="color: #007700">= </span><span style="color: #0000BB">imap_getmailboxes</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">, </span><span style="color: #DD0000">"{imap.example.org}"</span><span style="color: #007700">, </span><span style="color: #DD0000">"*"</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">is_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$list</span><span style="color: #007700">)) {<br /> foreach (</span><span style="color: #0000BB">$list </span><span style="color: #007700">as </span><span style="color: #0000BB">$key </span><span style="color: #007700">=> </span><span style="color: #0000BB">$val</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"($key) "</span><span style="color: #007700">;<br /> echo </span><span style="color: #0000BB">imap_utf7_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$val</span><span style="color: #007700">-></span><span style="color: #0000BB">name</span><span style="color: #007700">) . </span><span style="color: #DD0000">","</span><span style="color: #007700">;<br /> echo </span><span style="color: #DD0000">"'" </span><span style="color: #007700">. </span><span style="color: #0000BB">$val</span><span style="color: #007700">-></span><span style="color: #0000BB">delimiter </span><span style="color: #007700">. </span><span style="color: #DD0000">"',"</span><span style="color: #007700">;<br /> echo </span><span style="color: #0000BB">$val</span><span style="color: #007700">-></span><span style="color: #0000BB">attributes </span><span style="color: #007700">. </span><span style="color: #DD0000">"<br />\n"</span><span style="color: #007700">;<br /> }<br />} else {<br /> echo </span><span style="color: #DD0000">"imap_getmailboxes failed: " </span><span style="color: #007700">. </span><span style="color: #0000BB">imap_last_error</span><span style="color: #007700">() . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">imap_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.imap-getsubscribed.html" class="function" rel="rdfs-seeAlso">imap_getsubscribed()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imap-getacl.html">imap_getacl</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imap-getsubscribed.html">imap_getsubscribed</a></div> <div class="up"><a href="ref.imap.html">IMAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -