<?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-delete.php',
    1 => 'imap_delete',
    2 => 'Mark a message for deletion from current mailbox',
  ),
  'up' => 
  array (
    0 => 'ref.imap.php',
    1 => 'IMAP Functions',
  ),
  'prev' => 
  array (
    0 => 'function.imap-createmailbox.php',
    1 => 'imap_createmailbox',
  ),
  'next' => 
  array (
    0 => 'function.imap-deletemailbox.php',
    1 => 'imap_deletemailbox',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/imap/functions/imap-delete.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imap-delete" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imap_delete</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imap_delete</span> &mdash; <span class="dc-title">Mark a message for deletion from current mailbox</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imap-delete-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imap_delete</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">$message_nums</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></div>

  <p class="para rdfs-comment">
   Marks messages listed in <code class="parameter">message_nums</code> for deletion.
   Messages marked for deletion will stay in the mailbox until either
   <span class="function"><a href="function.imap-expunge.php" class="function">imap_expunge()</a></span> is called or
   <span class="function"><a href="function.imap-close.php" class="function">imap_close()</a></span> is called with the optional parameter
   <strong><code><a href="imap.constants.php#constant.cl-expunge">CL_EXPUNGE</a></code></strong>.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imap-delete-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">message_nums</code></dt>
     <dd>
      <p class="para">
       A <span class="type"><a href="language.types.string.php" class="type string">string</a></span> representing one or more messages in IMAP4-style sequence format
       (<code class="literal">&quot;n&quot;</code>, <code class="literal">&quot;n:m&quot;</code>, or combination of these
       delimited by commas).
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       You can set the <strong><code><a href="imap.constants.php#constant.ft-uid">FT_UID</a></code></strong> which tells the function
       to treat the <code class="parameter">message_nums</code> argument as a
       <code class="literal">UID</code>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imap-delete-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Always returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.imap-delete-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Throws a <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> if <code class="parameter">flags</code>
   is invalid.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imap-delete-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>

     <tr>
      <td>8.0.0</td>
      <td>
       A <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> is now thrown on invalid
       <code class="parameter">flags</code> parameter values. Previously,
       a warning was emitted and the function returned <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 examples" id="refsect1-function.imap-delete-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>imap_delete()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><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}INBOX"</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">)<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">$check </span><span style="color: #007700">= </span><span style="color: #0000BB">imap_mailboxmsginfo</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Messages before delete: " </span><span style="color: #007700">. </span><span style="color: #0000BB">$check</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Nmsgs </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br /&gt;\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">imap_delete</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$check </span><span style="color: #007700">= </span><span style="color: #0000BB">imap_mailboxmsginfo</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Messages after  delete: " </span><span style="color: #007700">. </span><span style="color: #0000BB">$check</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Nmsgs </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br /&gt;\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">imap_expunge</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$check </span><span style="color: #007700">= </span><span style="color: #0000BB">imap_mailboxmsginfo</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Messages after expunge: " </span><span style="color: #007700">. </span><span style="color: #0000BB">$check</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Nmsgs </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br /&gt;\n"</span><span style="color: #007700">;<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 notes" id="refsect1-function.imap-delete-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    IMAP mailboxes may not have their message flags saved between connections,
    so <span class="function"><a href="function.imap-expunge.php" class="function">imap_expunge()</a></span> should be called during the same
    connection in order to guarantee that messages marked for deletion will
    actually be purged.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imap-delete-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.imap-undelete.php" class="function" rel="rdfs-seeAlso">imap_undelete()</a> - Unmark the message which is marked deleted</span></li>
    <li><span class="function"><a href="function.imap-expunge.php" class="function" rel="rdfs-seeAlso">imap_expunge()</a> - Delete all messages marked for deletion</span></li>
    <li><span class="function"><a href="function.imap-close.php" class="function" rel="rdfs-seeAlso">imap_close()</a> - Close an IMAP stream</span></li>
   </ul>
  </p>
 </div>

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