PHP 8.4.2 Released!

imap_expunge

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

imap_expungeDelete all messages marked for deletion

Descrizione

imap_expunge(IMAP\Connection $imap): true

Deletes all the messages marked for deletion by imap_delete(), imap_mail_move(), or imap_setflag_full().

Elenco dei parametri

imap

An IMAP\Connection instance.

Valori restituiti

Always returns true.

Log delle modifiche

Versione Descrizione
8.1.0 The imap parameter expects an IMAP\Connection instance now; previously, a valid imap resource was expected.
add a note

User Contributed Notes 2 notes

up
11
boswachter at xs4all dot nl
18 years ago
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($box);

imap_expunge should not be in your inner loop.
up
4
Pavel Cernik
8 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