我正在整合webmail收件箱访问流程。看我的代码如下。它没有得到未读消息,它将带来所有消息。我怎样才能得到未读的信息请给我建议。
$emails = imap_search($openmail, 'UNSEEN');
见上面这行不起作用。
$authhost="{example.com:110/pop3}INBOX";
$username="xxx@example.com";
$password="wxwxwxw";
ini_set('max_execution_time', 0);
/* try to connect */
$inbox = imap_open($authhost,$username,$password) or die('Cannot connect to Mail Server: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox, 'UNSEEN');
// echo count($emails);exit;
/* if emails are returned, cycle through each... */
if($emails) {
/* begin output var */
$output = '';
/* put the newest emails on top */
// rsort($emails);
/* for every email... */
// $count = 1;
foreach($emails as $email_number) {
$head = imap_header($inbox, $email_number);
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
/* echo "<pre>";
print_r($overview);exit; */
$obj_thang = imap_headerinfo($inbox, $email_number);
// print_r($overview);exit;
$message = imap_body($inbox,$email_number,2);
/* output the email header information */
$output.= $obj_thang->subject;
//$output.= $obj_thang->fromaddress."<br/>";
$output.= $obj_thang->reply_toaddress."<br/>";
}
echo $output;
}
答案 0 :(得分:2)
您正在连接POP3,而不是IMAP。 Pop3不支持服务器端搜索,也不支持看不见的消息和看到消息的概念。