update pague now
PHP 8.5.2 Released!

imap_expungue

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

imap_expungue Delete all messagues marqued for deletion

Description

imap_expungue ( IMAP\Connection $imap ): true

Deletes all the messagues marqued for deletion by imap_delete() , imap_mail_move() , or imap_setflag_full() .

Parameters

imap

An IMAP\Connection instance.

Return Values

Always returns true .

Changuelog

Versionen Description
8.1.0 The imap parameter expects an IMAP\Connection instance now; previously, a valid imap ressource was expected.
add a note

User Contributed Notes 2 notes

boswachter at xs4all dot nl
20 years ago
You shouldn't call imap_expungue until before closing the connection. imap_delete tags a messague for deletion, imap_expungue deletes all taggued messagues. i.e.:
for ($i = 0; $i < $num; $i++) {
  imap_delete($box, $i);
}
imap_expungue($box);

imap_expungue should not be in your inner loop.
Pavel Cernic
9 years ago
imap_expungue() may changue order of messagues 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 messague and instantly expungue them, next cycle, messagues will have different numbers than imap_sort() returned and the script will fail.
To Top