Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: imap_delete - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

imap_deletemailbox" width="11" height="7"/> <imap_createmailbox
Last updated: Mon, 05 Feb 2007

view this page in

imap_delete

(PHP 4, PHP 5)

imap_delete — 現在のメールボックスから削除するメッセージに印を付ける

説明

bool imap_delete ( int imap_stream, int msg_number [, int options] )

msg_number が指すメッセージに 削除予定のマークをします。削除マークを付けられたメッセージは、 imap_expunge() がコールされるか imap_close()CL_EXPUNGE を付けてコールされるかのどちらかが行われるまでメールボックスに残ったままになります。

パラメータ

imap_stream

imap_open() が返す IMAP ストリーム。

msg_number

メッセージ番号。

options

FT_UID を指定すると、 引数 msg_numberUID として処理することを関数に指示できます。

返り値

Returns TRUE.

例 952. imap_delete() の例

<?php

$mbox
= imap_open("{imap.example.org}INBOX", "username", "password")
   or die(
"接続できません: " . imap_last_error());

$check = imap_mailboxmsginfo($mbox);
echo
"Messages before delete: " . $check->Nmsgs . "<br />\n";

imap_delete($mbox, 1);

$check = imap_mailboxmsginfo($mbox);
echo
"Messages after  delete: " . $check->Nmsgs . "<br />\n";

imap_expunge($mbox);

$check = imap_mailboxmsginfo($mbox);
echo
"Messages after expunge: " . $check->Nmsgs . "<br />\n";

imap_close($mbox);
?>

注意

注意: POP3 メールボックスは、コネクション間で保存可能なメッセージフラグを持っていません。 そのため、削除マークをつけたメッセージを本当に削除するためには、 同一の接続内で imap_expunge() をコールする必要があります。

参考

imap_undelete()
imap_expunge()
imap_close()



add a note add a note User Contributed Notes
imap_delete
jacky at jackyhome dot myvnc dot com
10-Nov-2003 06:42
// is not a complete code but enough to clear out an entire mailbox.
// hope this can save your time :-)

<?php

if (isset($_REQUEST['DoNow']))
{
 
# PULL ADDITIONAL FILES
 
include_once ("common.php");
 
 
$conn = @imap_open("\{$server/$serverType}Trash", $user, $pass)
  or die(
"Connection to folder failed");
 
 
$headers = @imap_check($conn);
  (
$headers->Nmsgs > 0) or die("Trash is empty already !");
 
 
// delete email(s)
 
@imap_delete($conn,'1:*');  // to clear out an entire mailbox.
 
@imap_expunge($conn);
  echo
"Trash is empty.";
 
 
imap_close($conn);
}
else
{
  echo
"<form name='formA' action='".$_SERVER['PATH_INFO']."' method='POST'>"; ?>
  Are you sure to empty trash ?
  <p>
  <input type="submit" value="Go Ahead" name="DoNow">&nbsp;
  <input type="button" value="Cancel" name="Cancel" onClick='javascript:self.history.go(-1)'></form></p>
<?php
} ?>
James G
10-Apr-2003 01:05
I had some major issues deleting emails using this function.  Using IIS 5.0 and a win based Mail Server, I could not delete the emails individually.

My script merely needed to check the emails and update the database for bounce backs, after which I simply wanted to erase all emails.

If imap_delete($mbox,$email->MsgNo) just isnt working for you, you can try using

   imap_delete($mbox,'1:*');

to clear out an entire mailbox.

Hope this helps cause it drove me insane for about 5 hours.  :)

 
show source | credits | sitemap | contact | advertising | mirror sites