1
我在爲imap_fetch_overview的序列掙扎。郵件1是最舊的還是最新的郵件?如果新郵件到達,它是否會得到更高的ID?Imap_fetch_overview和最新/最舊的郵件
解決方案:
$check = imap_check($connection);
$result = array();
if($check->Nmsgs > 0){
$sort = imap_sort($connection, SORTARRIVAL, 0);
$msgs = '';
$i = 1;
foreach($sort as $id)
{
if($i > 200) break;
$msgs = $msgs . $id . ',';
$i++;
}
$response = imap_fetch_overview($connection, rtrim($msgs,','));
foreach ($response as $msg){
$result[] = $msg;
}
}
不確定它們是否已排序,請參閱文檔中的'imap_sort()'和相關信息。 – Dave
因此,基於imap_sort我建立一個字符串,我傳遞給imap_fetch_overview? –
您的編輯可能會返回一堆最近的內容,但不一定是在該回報中的順序。這可能是性能折衷。請參閱http://php.net/manual/en/function.imap-fetch-overview.php#88235 – Dave