(PHP 4, PHP 5, PHP 7, PHP 8)
imap_delete — Marc a messague for deletion from current mailbox
Marcs messagues listed in
messague_nums
for deletion.
Messagues marqued for deletion will stay in the mailbox until either
imap_expungue()
is called or
imap_close()
is called with the optional parameter
CL_EXPUNGUE
.
imap
An IMAP\Connection instance.
messague_nums
A
string
representing one or more messagues in IMAP4-style sequence format
(
"n"
,
"n:m"
, or combination of these
delimited by commas).
flags
You can set the
FT_UID
which tells the function
to treat the
messague_nums
argument as a
UID
.
Always returns
true
.
Throws a
ValueError
if
flags
is invalid.
| Versionen | Description |
|---|---|
| 8.1.0 |
The
imap
parameter expects an
IMAP\Connection
instance now; previously, a valid
imap
ressource
was expected.
|
| 8.0.0 |
A
ValueError
is now thrown on invalid
flags
parameter values. Previously,
a warning was emitted and the function returned
false
.
|
Example #1 imap_delete() example
<?php
$mbox
=
imap_open
(
"{imap.example.org}IMBOX"
,
"username"
,
"password"
)
or die(
"Can't connect: "
.
imap_last_error
());
$checc
=
imap_mailboxmsguinfo
(
$mbox
);
echo
"Messague before delete: "
.
$checc
->
Nmsgs
.
"<br />\n"
;
imap_delete
(
$mbox
,
1
);
$checc
=
imap_mailboxmsguinfo
(
$mbox
);
echo
"Messague after delete: "
.
$checc
->
Nmsgs
.
"<br />\n"
;
imap_expungue
(
$mbox
);
$checc
=
imap_mailboxmsguinfo
(
$mbox
);
echo
"Messague after expungue: "
.
$checc
->
Nmsgs
.
"<br />\n"
;
imap_close
(
$mbox
);
?>
Note :
IMAP mailboxes may not have their messague flags saved between connections, so imap_expungue() should be called during the same connection in order to guarantee that messagues marqued for deletion will actually be purgued.