PHP - imap_setflag_full() 函式



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

**imap_setflag_full()** 函式接收表示 IMAP 流的資源值、表示訊息編號序列的兩個字串值和標誌作為引數,並在給定的訊息上設定指定的標誌。

語法

imap_setflag_full($imap_stream, $sequence, $flag [, $options]);

引數

序號 引數及描述
1

imap_stream (必填)

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

2

sequence (必填)

這是一個字串值,表示訊息編號的序列。您也可以指定訊息的區間,例如 4:12。

3

flag (必填)

這是一個字串值,表示要移除的標誌值("\\Seen","\\Answered","\\Flagged","\\Deleted" 和 "\\Draft")。

4

Options (可選)

這是一個整數值,表示可選值 ST_UID,如果指定,則需要傳遞 UID 而不是序列號。

返回值

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

PHP 版本

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

示例

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

<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>");
		 		 
         $res = imap_setflag_full($imap, "2,5", "\\Seen \\Flagged");
         if($res){
            print("Messages Were Flagged");
         }else{
            print("Error Occurred");
         }
         //Closing the connection
         imap_close($imap);   		 
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Connection established....
Messages Were Flagged

示例

以下是帶可選引數的上述函式示例:

<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>");
             
         $list = imap_uid($imap, 2)."".imap_uid($imap, 5);		 
         $res = imap_setflag_full($imap, $list, "\\Seen \\Flagged", ST_UID);
         print("Messages Were Flagged");   
		   
         //Closing the connection
         imap_close($imap);   		 
      
      ?>
   </body>
</html>

輸出

這將生成以下輸出:

Connection established....
Messages Were Flagged
php_function_reference.htm
廣告