PHP 8.3.4 Released!

imap_expunge

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

imap_expunge削除用にマークされたすべてのメッセージを削除する

説明

imap_expunge(IMAP\Connection $imap): true

imap_delete()imap_mail_move()、 あるいは imap_setflag_full() で削除用マークを設定されたすべてのメッセージを削除します。

パラメータ

imap

IMAP\Connection クラスのインスタンス。

戻り値

常に true を返します。

変更履歴

バージョン 説明
8.1.0 引数 imap は、IMAP\Connection クラスのインスタンスを期待するようになりました。 これより前のバージョンでは、有効な imap リソース が期待されていました。
add a note

User Contributed Notes 2 notes

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

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