实际上我正在使用 imap 功能,但问题是我得到的计数是我想要计数的所有电子邮件,这些电子邮件给我未读邮件计数谁能告诉我我该怎么做。我可以删除看到的邮件,然后它工作正常,但我想保留邮件并阅读未读的邮件。
我正在这门课上寻求帮助
for ($i = 0; $i < $total_messages; $i++) {
$email = $vars->email_get($i+1);
$ismsgdb = $vars->db_add_message($email); // vars INSERTS EACH MSG INTO DATABASE
#Get store dir
$dir = $vars->dir_name();
$id_log = $vars->add_db_log($email, 'Copy e-mail - start ');
foreach($vars->partsarray as $part){
if($part[text][type] == 'HTML'){
#$message_HTML = $part[text][string];
$vars->db_update_message($part[text][string], $type= 'HTML');
}
elseif($part[text][type] == 'PLAIN'){
$message_PLAIN = $part[text][string];
$vars->db_update_message($part[text][string], $type= 'PLAIN');
}
elseif($part[attachment]){
#Save files(attachments) on local disc
foreach(array($part[attachment]) as $attach){
$attach[filename] = $vars->mimie_text_decode($attach[filename]);
$attach[filename] = preg_replace('/[^a-z0-9_\-\.]/i', '_', $attach[filename]);
$vars->add_db_log($email, 'Start coping file:"'.strip_tags($attach[filename]).'"');
$vars->save_files($vars->newid.$attach[filename], $attach[string]);
$filename = $dir.$vars->newid.$attach[filename];
$vars->db_add_attach($attach[filename], $filename);
$vars->update_db_log('<b>'.$filename.'</b>Finish coping: "'.strip_tags($attach[filename]).'"', $vars->logid);
}
}elseif($part[image]){
#Save files(attachments) on local disc
$message_IMAGE[] = $part[image];
foreach($message_IMAGE as $image){
$image[filename] = $vars->mimie_text_decode($image[filename]);
$image[filename] = preg_replace('/[^a-z0-9_\-\.]/i', '_', $image[filename]);
$vars->add_db_log($email, 'Start coping file: "'.strip_tags($image[filename]).'"');
$vars->save_files($vars->newid.$image[filename], $image[string]);
$filename = $dir.$vars->newid.$image[filename];
$vars->db_add_attach($image[filename], $filename);
$vars->update_db_log('<b>'.$filename.'</b>Finish
coping:"'.strip_tags($image[filename]).'"', $vars->logid);
}
}
}
$vars->spam_detect();
$vars->email_setflag();
//$vars->email_delete(); // WHEN I REMOVE vars THE SCRIPT WONT GRAB NEW EMAILS
//$vars->email_expunge(); // WHEN I REMOVE vars THE SCRIPT WONT GRAB NEW EMAILS
$vars->update_db_log('Finish coping', $id_log);
}