Spent ages trying to get this to work, then eventually remembered I had opened the mailbox READONLY - obviously you need write permission for setting flags!
(PHP 4, PHP 5, PHP 7, PHP 8)
imap_setflag_full — メッセージにフラグをセットする
この関数は、指定した sequence
のメッセージの
フラグに指定した flag
を設定し、保存します。
imap
IMAP\Connection クラスのインスタンス。
sequence
メッセージ番号のシーケンス。
X,Y
形式でメッセージを列挙したり、
X:Y
形式で範囲内のすべてのメッセージを指定したりすることができます。
flag
設定可能なフラグは、(» RFC2060
で定義された) \Seen
、
\Answered
、\Flagged
、
\Deleted
および \Draft
です。
options
options
はビットマスクであり、以下の組み合わせとなります。
ST_UID
- シーケンス引数はシーケンス番号の代わりに
UID を含みます。
常に true
を返します。
options
が無効な場合、
ValueError がスローされます。
バージョン | 説明 |
---|---|
8.1.0 |
引数 imap は、IMAP\Connection
クラスのインスタンスを期待するようになりました。
これより前のバージョンでは、有効な imap リソース が期待されていました。
|
8.0.0 |
options が無効な値の場合、
ValueError がスローされるようになりました。
これより前のバージョンでは、
警告が発生し、false を返していました。
|
例1 imap_setflag_full() の例
<?php
$mbox = imap_open("{imap.example.org:143}", "username", "password")
or die("接続できません: " . imap_last_error());
$status = imap_setflag_full($mbox, "2,5", "\\Seen \\Flagged");
echo gettype($status) . "\n";
echo $status . "\n";
imap_close($mbox);
?>
Spent ages trying to get this to work, then eventually remembered I had opened the mailbox READONLY - obviously you need write permission for setting flags!
Where possible I would avoid using POP3 accounts. My host allowed me to upgrade to IMAP and it is so much easier. I think the only way to accurately create any form of mail client with POP3 is to download the messages into an SQL database which is a big task to start with, considering the IMAP standards have the functionality we need built in.I experimented with flag setting in POP3 and it seems they do not stick at all, and it is almost impossible to retrieve the number of unread messages (ie. the Seen / Unseen thing does not work)Converted to IMAP and it's working - the majority of the functions in this section seem to be IMAP focussed and WILL NOT generally work with POP3