PHP - imap_undelete() 函式



PHP 的 IMAP 函式幫助您訪問電子郵件帳戶,IMAP 代表 **I**nternet **M**ail **A**ccess **P**rotocol,使用這些函式您還可以使用 NNTP、POP3 協議和本地郵箱訪問方法。

imap_undelete() 函式接受表示 IMAP 流的資源值和表示郵箱中郵件的整數值作為引數,並將標記為刪除(使用 delete() 函式)的郵件標記為未刪除。

語法

imap_undelete($imap_stream, $msg);

引數

序號 引數及描述
1

imap_stream (必填)

這是一個字串值,表示 IMAP 流,是 imap_open() 函式的返回值。

2

msg (必填)

這是一個整數值,表示要標記為未刪除的郵件/郵件編號。

3

flags (可選)

這是一個可選引數,表示標誌。

返回值

此函式返回一個布林值,成功時為 TRUE,失敗時為 FALSE。

PHP 版本

此函式首次在 PHP 4 版本中引入,並在所有後續版本中可用。

示例

以下示例演示了 imap_undelete() 函式的用法:

<html>
   <body>
      <?php
         //Establishing connection
         $url = "{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX";
         $id = "tutorialspoint.test@gmail.com";
         $pwd = "cohondob_123";
         $imap = imap_open($url, $id, $pwd);
         print("Connection established...."."<br>");
		 		 
         //Marking message for deletion
         $res = imap_delete($imap, 4);

         if($res){
            print("Message marked for deletion"."<br>");
         }		 
         //Deleting messages
         $res = imap_undelete($imap, 4);	 	
         if($res){
            print("Message un-marked successfully"."<br>");
         } else {
            print("Error Occured");
         }	 		 
         //Closing the connection
         imap_close($imap);   
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Connection established....
Message marked for deletion
Message un-marked successfully
php_function_reference.htm
廣告