PHP-IMAP命令存储中出错:消息集无效

PHP-IMAP命令存储中出错:消息集无效,php,imap,Php,Imap,我将imap与php一起使用,发现以下错误: 未知:IMAP协议错误:IMAP命令存储中的错误:无效消息集(0.001+0.000秒)。(errflg=2) 这种情况只发生在某些邮箱中(例如托管在misterdomain.eu上的邮箱) 错误发生在脚本末尾,在imap\u close()之后 这是简单的代码。如果你有任何建议(远不止我的第一个问题),我真的接受了 $inbox = imap_open($hostname,$username,$password) or die('Cannot co

我将imap与php一起使用,发现以下错误:

未知:IMAP协议错误:IMAP命令存储中的错误:无效消息集(0.001+0.000秒)。(errflg=2)

这种情况只发生在某些邮箱中(例如托管在misterdomain.eu上的邮箱)

错误发生在脚本末尾,在imap\u close()之后

这是简单的代码。如果你有任何建议(远不止我的第一个问题),我真的接受了

$inbox = imap_open($hostname,$username,$password) or die('Cannot connect: ' . imap_last_error());
$emails = imap_search($inbox,'SINCE "'.date("d-M-y",strtotime("-3 days")).'"',SE_UID);

if($emails) {
    rsort($emails);
    foreach($emails as $email_number) {

        echo "<h1>".$email_number."</h1>";
        $overview = imap_fetch_overview($inbox,$email_number, FT_UID);

        if($overview[0]->seen)
            imap_clearflag_full($inbox,$email_number,"//Seen");
        else
            imap_clearflag_full($inbox,$email_number,"//Unseen");

        $structure = imap_fetchstructure($inbox,$email_number, FT_UID);

        if(isset($structure->parts)){
            $flattenedParts = flattenParts($structure->parts);
            echo "<pre>";
            print_r($flattenedParts);
            echo "</pre>";
            echo "</br>";           
            getmsg($inbox, $email_number);

            echo "<p>".htmlspecialchars_decode(utf8_decode($plainmsg))."</p>";
        }else{
            $string_email = utf8_decode(imap_body($inbox, $email_number, FT_UID));
            $string_email= strip_tags($string_email);
            $string_email = html_entity_decode($string_email,ENT_QUOTES);
            echo "<p>".$string_email."</p>";
        }

    }
} 
imap_close($inbox);
$inbox=imap_open($hostname,$username,$password)或die('cannotconnect:'。imap_last_error());
$emails=imap_search($inbox,'SINCE'.date(“d-M-y”,strottime(“-3天”)。”,seu-UID);
如果($电子邮件){
rsort(电子邮件);
foreach($email作为$email\u编号){
回显“$email_number.”;
$overview=imap\U fetch\U overview($inbox,$email\u number,FT\u UID);
如果($overview[0]->已看到)
imap_clearflag_full($inbox,$email_number,///Seen);
其他的
imap_clearflag_full($inbox,$email_number,//Unseen”);
$structure=imap\u fetchstructure($inbox,$email\u number,FT\u UID);
if(isset($structure->parts)){
$FlattedParts=FlattedParts($structure->parts);
回声“;
打印(扁平零件);
回声“;
回声“
”; getmsg($inbox,$email_number); echo“”.htmlspecialchars\u decode(utf8\u decode($plainmsg))。“

”; }否则{ $string_email=utf8_解码(imap_body($inbox,$email_number,FT_UID)); $string\u email=strip\u标签($string\u email); $string\u email=html\u entity\u decode($string\u email,ENT\u引号); 回送“”$string_电子邮件。”

”; } } } imap_关闭($收件箱);
您使用UID进行搜索和获取,但使用消息序列号进行存储。这些邮件编号方式不匹配,因此您正在向存储发送无效的邮件编号。将适当的ST_UID标志添加到imap_clearflag_full

此外,系统标志使用反斜杠,而不是正斜杠:
'\\Seen'

\Unseen
不是定义的标志。您可能想添加
\Seen
标志。

真的吗!所以,如果我读了一封“未读”的邮件,它仍然是“未读的”?我不清楚你试图通过设置/清除标志来完成什么。只要您使用的是fetch函数的PEEK变体,标志就不应该改变。好的,很清楚。我不想更改“已看到”的状态(如果以前未读过,则允许未读)。谢谢!