PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

imap_deletemailbox> <imap_createmailbox
Last updated: Fri, 22 Aug 2008

view this page in

imap_delete

(PHP 4, PHP 5)

imap_deleteMarcar un mensaje para su borrado del buzón actual

Descripción

bool imap_delete ( int $secuencia_imap , int $numero_mensaje [, int $opciones ] )

Marca los mensajes listados en numero_mensaje para su eliminación. Los mensajes marcados para eliminicaín permanecerán en el buzón hasta que se llame imap_expunge() o imap_close() con el parámetro opcional CL_EXPUNGE.

Lista de parámetros

imap_stream

An IMAP stream returned by imap_open().

numero_mensaje

El número de mensaje

opciones

Es posible usar el valor FT_UID que indica que la función debe tratar el argumento numero_mensaje como un UID.

Valores retornados

Devuelve TRUE.

Ejemplos

Example #1 Ejemplo de imap_delete()

<?php

$buzon 
imap_open("{imap.example.org}INBOX""usuario""contraseña")
    or die(
"No es posible conectarse: " imap_last_error());

$chequeo imap_mailboxmsginfo($buzon);
echo 
"Mensajes antes de borrar: " $chequeo->Nmsgs "<br />\n";

imap_delete($buzon1);

$chequeo imap_mailboxmsginfo($buzon);
echo 
"Mensajes después de borrar: " $chequeo->Nmsgs "<br />\n";

imap_expunge($buzon);

$chequeo imap_mailboxmsginfo($buzon);
echo 
"Mensajes después de purgar: " $chequeo->Nmsgs "<br />\n";

imap_close($buzon);
?>

Notes

Note: Los buzones POP3 no guardan sus banderas de mensajes entre conexiones, así que imap_expunge() debe llamarse en la misma conexión para que los mensajes marcados para eliminación sean realmente removidos.



add a note add a note User Contributed Notes
imap_delete
jacky at jackyhome dot myvnc dot com
09-Nov-2003 10:42
// is not a complete code but enough to clear out an entire mailbox.
// hope this can save your time :-)

<?php

if (isset($_REQUEST['DoNow']))
{
 
# PULL ADDITIONAL FILES
 
include_once ("common.php");
 
 
$conn = @imap_open("\{$server/$serverType}Trash", $user, $pass)
  or die(
"Connection to folder failed");
 
 
$headers = @imap_check($conn);
  (
$headers->Nmsgs > 0) or die("Trash is empty already !");
 
 
// delete email(s)
 
@imap_delete($conn,'1:*');   // to clear out an entire mailbox.
 
@imap_expunge($conn);
  echo
"Trash is empty.";
 
 
imap_close($conn);
}
else
{
  echo
"<form name='formA' action='".$_SERVER['PATH_INFO']."' method='POST'>"; ?>
  Are you sure to empty trash ?
  <p>
  <input type="submit" value="Go Ahead" name="DoNow">&nbsp;
  <input type="button" value="Cancel" name="Cancel" onClick='javascript:self.history.go(-1)'></form></p>
<?php
} ?>
James G
10-Apr-2003 06:05
I had some major issues deleting emails using this function.  Using IIS 5.0 and a win based Mail Server, I could not delete the emails individually.

My script merely needed to check the emails and update the database for bounce backs, after which I simply wanted to erase all emails.

If imap_delete($mbox,$email->MsgNo) just isnt working for you, you can try using

    imap_delete($mbox,'1:*');

to clear out an entire mailbox.

Hope this helps cause it drove me insane for about 5 hours.  :)

imap_deletemailbox> <imap_createmailbox
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites