PHP 8.1.0 RC 4 available for testing


(PHP 4, PHP 5, PHP 7, PHP 8)

imap_expungeEfface tous les messages marqués pour l'effacement


imap_expunge(IMAP\Connection $imap): bool

Efface tous les messages marqués pour l'effacement par imap_delete(), imap_mail_move(), ou imap_setflag_full().

Liste de paramètres


Une instance de IMAP\Connection.

Valeurs de retour

Retourne true.


Version Description
8.1.0 La paramètre imap attend désormais une instance de IMAP\Connection ; auparavant, une ressource était attendu.
add a note add a note

User Contributed Notes 2 notes

boswachter at xs4all dot nl
15 years ago
@eisbrenner at gidn dot de

You shouldn't call imap_expunge until before closing the connection. imap_delete tags a message for deletion, imap_expunge deletes all tagged messages. i.e.:
for ($i = 0; $i < $num; $i++) {
  imap_delete($box, $i);

imap_expunge should not be in your inner loop.
Pavel Cernik
5 years ago
imap_expunge() may change order of messages which were loaded using imap_sort().
That means, if you use foreach() on result of imap_sort() function and each pass you move/delete a message and instantly expunge them, next cycle, messages will have different numbers than imap_sort() returned and the script will fail.
To Top