<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.imap.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.imap-getmailboxes.php',
    1 => 'imap_getmailboxes',
    2 => 'Read the list of mailboxes, returning detailed information on each one',
  ),
  'up' => 
  array (
    0 => 'ref.imap.php',
    1 => 'IMAP Functions',
  ),
  'prev' => 
  array (
    0 => 'function.imap-getacl.php',
    1 => 'imap_getacl',
  ),
  'next' => 
  array (
    0 => 'function.imap-getsubscribed.php',
    1 => 'imap_getsubscribed',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/imap/functions/imap-getmailboxes.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imap-getmailboxes" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imap_getmailboxes</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imap_getmailboxes</span> &mdash; <span class="dc-title">Read the list of mailboxes, returning detailed information on each one</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imap-getmailboxes-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imap_getmailboxes</strong></span>(<span class="methodparam"><span class="type"><a href="class.imap-connection.php" class="type IMAP\Connection">IMAP\Connection</a></span> <code class="parameter">$imap</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$reference</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$pattern</code></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Gets information on the mailboxes.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imap-getmailboxes-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    <dt>
<code class="parameter">imap</code></dt><dd><p class="para">An <span class="classname"><a href="class.imap-connection.php" class="classname">IMAP\Connection</a></span> instance.</p></dd>
    
     <dt><code class="parameter">reference</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">reference</code> should normally be just the server
       specification as described in <span class="function"><a href="function.imap-open.php" class="function">imap_open()</a></span>
      </p>
      <div class="warning"><strong class="warning">Warning</strong><p class="simpara">
Passing untrusted data to this parameter is <em>insecure</em>, unless
<a href="imap.configuration.php#ini.imap.enable-insecure-rsh" class="link">imap.enable_insecure_rsh</a> is disabled.
</p></div>
     </dd>
    
    
     <dt><code class="parameter">pattern</code></dt>
     <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 <code class="parameter">pattern</code>:
&#039;<code class="literal">*</code>&#039; and &#039;<code class="literal">%</code>&#039;.
&#039;<code class="literal">*</code>&#039; means to return all mailboxes. If you pass
<code class="parameter">pattern</code> as &#039;<code class="literal">*</code>&#039;, you will
get a list of the entire mailbox hierarchy.
&#039;<code class="literal">%</code>&#039;
means to return the current level only.
&#039;<code class="literal">%</code>&#039; as the <code class="parameter">pattern</code>
parameter will return only the top level
mailboxes; &#039;<code class="literal">~/mail/%</code>&#039; on <code class="literal">UW_IMAPD</code> will return every mailbox in the <var class="filename">~/mail</var> directory, but none in subfolders of that directory.</p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imap-getmailboxes-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an array of objects containing mailbox information. Each
   object has the attributes <code class="parameter">name</code>, specifying
   the full name of the mailbox; <code class="parameter">delimiter</code>,
   which is the hierarchy delimiter for the part of the hierarchy
   this mailbox is in; and
   <code class="parameter">attributes</code>. <code class="parameter">Attributes</code>
   is a bitmask that can be tested against:
   <ul class="itemizedlist">
    <li class="listitem">
     <p class="para">
      <strong><code><a href="imap.constants.php#constant.latt-noinferiors">LATT_NOINFERIORS</a></code></strong> - This mailbox not contains, and may not contain any
      &quot;children&quot; (there are no mailboxes below this one). Calling 
      <span class="function"><a href="function.imap-createmailbox.php" class="function">imap_createmailbox()</a></span> will not work on this mailbox.
     </p>
    </li>
   <li class="listitem">
     <p class="para">
      <strong><code><a href="imap.constants.php#constant.latt-noselect">LATT_NOSELECT</a></code></strong> - This is only a container,
      not a mailbox - you cannot open it.
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code><a href="imap.constants.php#constant.latt-marked">LATT_MARKED</a></code></strong> - 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">
      <strong><code><a href="imap.constants.php#constant.latt-unmarked">LATT_UNMARKED</a></code></strong> - This mailbox is not marked, does not contain new
      messages.  If either <strong><code>MARKED</code></strong> or <strong><code>UNMARKED</code></strong> is
      provided, you can assume the IMAP server  supports this feature for this mailbox.
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code><a href="imap.constants.php#constant.latt-referral">LATT_REFERRAL</a></code></strong> - This container has a referral to a remote mailbox.
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code><a href="imap.constants.php#constant.latt-haschildren">LATT_HASCHILDREN</a></code></strong> - This mailbox has selectable inferiors.
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code><a href="imap.constants.php#constant.latt-hasnochildren">LATT_HASNOCHILDREN</a></code></strong> - This mailbox has no selectable inferiors.
     </p>
    </li>
   </ul>
   The function returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imap-getmailboxes-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  The <code class="parameter">imap</code> parameter expects an <span class="classname"><a href="class.imap-connection.php" class="classname">IMAP\Connection</a></span>
  instance now; previously, a valid <code class="literal">imap</code> <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> was expected.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 examples" id="refsect1-function.imap-getmailboxes-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>imap_getmailboxes()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?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">=&gt; </span><span style="color: #0000BB">$val</span><span style="color: #007700">) {<br />        echo </span><span style="color: #DD0000">"(</span><span style="color: #0000BB">$key</span><span style="color: #DD0000">) "</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">-&gt;</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">-&gt;</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">-&gt;</span><span style="color: #0000BB">attributes </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br /&gt;\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">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imap-getmailboxes-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.imap-getsubscribed.php" class="function" rel="rdfs-seeAlso">imap_getsubscribed()</a> - List all the subscribed mailboxes</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>