我正在尝试阅读电子邮件中的消息...根据主题的内容,我想将其移动到“进程”或“未经授权”文件夹
将消息保存在一个数组中,然后将消息从收件箱移动到 Proceeded 文件夹
这是我所做的
// Checks the inbox
if ($messages = imap_search($this->conn,'ALL'))
{
// Sorts the messages newest first
rsort($messages);
// Loops through the messages
foreach ($messages as $id)
{
$header = imap_headerinfo($this->conn, $id);
$message = imap_fetchbody($this->conn, $id, 1);
if( !isset($header->from[0]->mailbox) || empty($header->from[0]->mailbox)
|| !isset($header->from[0]->host) || empty($header->from[0]->host)
|| !isset($header->subject) || empty($header->from[0]->host)
) {
continue;
}
$from = $header->from[0]->mailbox . '@' . $header->from[0]->host;
$subject = $header->subject;
$outlook = $this->_parseReplyExchange($message);
if($outlook !== false){
$newReply = $outlook;
} else {
$newReply = $this->_parseReplySystem($message);
}
$ticketID = $this->_parseTicketID($subject);
if($ticketID !== false){
$f = array();
$f['id'] = $id;
$f['from'] = $from;
$f['subject'] = $subject;
$f['ticketID'] = $ticketID;
$f['message'] = $newReply;
$this->replyList[] = $f;
$imapresult = imap_mail_move($this->conn, $id, $box, CP_UID);
if($imapresult == false){
echo imap_last_error();
}
}
}
}
else
{
exit('No messages on the IMAP server.');
}
我毫无问题地阅读了该消息,但在尝试移动该消息时出现错误。
.[TRYCREATE] The requested item could not be found.
Notice: Unknown: [TRYCREATE] The requested item could not be found. (errflg=2) in Unknown on line 0
我认为问题在于我如何将 $id 传递给imap_mail_move
函数。
我还尝试将消息序列号转换为像这样的 UID 号$f['id'] = imap_uid($this->conn , $id )
,但这不起作用..
我也试过这个
$imapresult = imap_mail_move($this->conn, '1:' . $id, $box);
$imapresult = imap_mail_move($this->conn, '1:' . $id, $box, CP_UID);
我什至尝试复制然后删除该消息,但没有成功。
$imapresult = imap_mail_copy($c, '1', 'INBOX/Processed', CP_MOVE);
我无法让消息移动。
如何正确移动消息?