PHP-IMAP 函數可幫助您訪問電子郵件帳戶,IMAP 代表I互聯網M艾爾A訪問權限Protocol 使用這些函數您還可以使用 NNTP、POP3 協議和本地郵箱訪問方法。
這個imap_setflag_full()函數接受一個表示 IMAP 流的資源值,兩個表示消息編號序列的字符串值,以及作為參數的標誌,並在給定的消息上設置指定的標誌。
用法
imap_setflag_full($imap_stream, $sequence, $flag [, $options]);
參數
Sr.No | 參數及說明 |
---|---|
1 |
imap_stream (Mandatory) 這是一個表示 IMAP 流的字符串值,返回值imap_open()函數。 |
2 |
sequence(Mandatory) 這是一個字符串值,表示消息編號的序列。您還可以將消息間隔指定為 4:12。 |
3 |
flag(Mandatory) 這是一個字符串值,表示要移除的標誌值("\\Seen"、"\\Answered"、"\\Flagged"、"\\Deleted" 和 "\\Draft")。 |
4 |
Options(Optional) 這是一個整數值,表示可選值 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 imap_set_quota()用法及代碼示例
- PHP imap_search()用法及代碼示例
- PHP imap_status()用法及代碼示例
- PHP imap_savebody()用法及代碼示例
- PHP imap_subscribe()用法及代碼示例
- PHP imap_scanmailbox()用法及代碼示例
- PHP imap_scan()用法及代碼示例
- PHP imap_sort()用法及代碼示例
- PHP imap_getsubscribed()用法及代碼示例
- PHP imap_header()用法及代碼示例
- PHP imap_last_error()用法及代碼示例
- PHP imap_mutf7_to_utf8()用法及代碼示例
- PHP imap_headerinfo()用法及代碼示例
- PHP imap_lsub()用法及代碼示例
- PHP imap_createmailbox()用法及代碼示例
- PHP imap_fetchtext()用法及代碼示例
- PHP imap_listmailbox()用法及代碼示例
- PHP imap_timeout()用法及代碼示例
- PHP imap_num_msg()用法及代碼示例
- PHP imap_undelete()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - imap_setflag_full() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。