#10536 [Com]: imap_expunge() can't really expunge mail
| From: | fisting-cum1492 at hotmail dot com | Date: | Tue, 20 Jul 2004 15:01:40 +0000 |
| Subject: | #10536 [Com]: imap_expunge() can't really expunge mail | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-62818@lists.php.net to get a copy of this message | ||
ID: 10536
Comment by: fisting-cum1492 at hotmail dot com
Reported By: cwyeh at ccca dot nctu dot edu dot tw
Status: Bogus
Bug Type: IMAP related
Operating System: FreeBSD 4.3
PHP Version: 4.0.4pl1
New Comment:
<a href=http://kcum-coveredfeetfis.da.ru>fisting
cum</a>
Previous Comments:
------------------------------------------------------------------------
[2001-04-28 13:40:19] chagenbu@php.net
Your second example is correct, and is also a heck of a lot more
efficient.
The first example doesn't work because every time you call
imap_expunge(), the pop3 server actually deletes the messages, and the
message numbers change. So if you have messages 1, 2, 3, 4, you delete
1, and you call imap_expunge, you don't have 2, 3, 4, you have 1, 2, 3.
Your code then tries to delete number 2, leaving you with 1, 2 ... you
see where this is going.
------------------------------------------------------------------------
[2001-04-28 10:25:50] cwyeh at ccca dot nctu dot edu dot tw
As I wrote the following code I found the strong situation in
imap_expunge(). It will expunge mails with odd number only but not
every mail as I expected.
$mbox = imap_open("{localhost/pop3:110INBOX", "test", "test");
$num_msg = imap_num_msg($mbox);
echo "start at $num_msg...<br>";
for ( $i=1; $i<=$num_msg; $i++ ) {
imap_delete($mbox, $i);
imap_expunge($mbox);
echo "doing $i....<br>";
}
imap_expunge($mbox);
$num_msg = imap_num_msg($mbox);
echo "now is $num_msg<br>";
imap_close($mbox);
I have the following output:
start at 10...
doing 1....
doing 2....
doing 3....
doing 4....
doing 5....
doing 6....
doing 7....
doing 8....
doing 9....
doing 10....
now is 5
If I modify the code as following the problem solved:
for ( $i=1; $i<=$num_msg; $i++ ) {
imap_delete($mbox, $i);
echo "doing $i....<br>";
}
imap_expunge($mbox);
The result is coreect and all mail has been deleted.
This bug occurs if a web mail system with a pop server try to delete
lots of spam at a time.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=10536&edit=1