Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php imap_setflag_full无法更改邮件状态_Php_Email_Imap - Fatal编程技术网

Php imap_setflag_full无法更改邮件状态

Php imap_setflag_full无法更改邮件状态,php,email,imap,Php,Email,Imap,我用下面的代码来阅读我的gmail收件箱,它的阅读效果很好 但问题是,有些邮件并没有像我们看到的那样设置好,所以它们每次都会出现 根据我的观察,从看不见到看不见的标志没有改变的邮件是包含一些HTML的邮件 下面是我的代码: public function getMessages($type = 'text') { $stream = $this->imapStream; $emails = imap_search($stream, 'UNSEEN');

我用下面的代码来阅读我的gmail收件箱,它的阅读效果很好

但问题是,有些邮件并没有像我们看到的那样设置好,所以它们每次都会出现

根据我的观察,从看不见到看不见的标志没有改变的邮件是包含一些HTML的邮件

下面是我的代码:

 public function getMessages($type = 'text') {
        $stream = $this->imapStream;
        $emails = imap_search($stream, 'UNSEEN');
        $messages = array();
        if ($emails) {
            $this->emails = $emails;
            $i = 0;
            foreach ($emails as $email_number) {
                $this->attachments = array();
                $uid = imap_uid($stream, $email_number);
                $messages[] = $this->loadMessage($uid, $type);
                if ($i == $this->limit) {
                    break;
                }
                $i++;
                echo "seen status=>".imap_setflag_full($stream, $email_number, "\\Seen", ST_UID);
                //echo "seen status=>".imap_clearflag_full($stream, $email_number, "\\Seen");
            }
        }
        return $messages;
    }
这是我用来手动更改状态的行

echo "seen status=>".imap_setflag_full($stream, $email_number, "\\Seen", ST_UID);

SEED status始终返回1作为结果,但在收件箱中显示为未读。

您使用的是消息序列号(MSN),但为您的标志函数提供了
ST\u UID
标志,将其更改为使用UID。大多数MSN通常不是有效的UID

在任何地方使用UID(所有函数都使用
FT\u UID
ST\u UID
等)或MSN(不要使用UID标志,也不要在循环时删除任何内容。)

如果使用UID版本的搜索,则不需要调用
imap\u UID

imap_setflag_full($stream, $email_number, "\\Seen");
imap_setflag_full($stream, $uid, "\\Seen", ST_UID);