我正在使用imap_fetchheader函数从Gmail帐户获取未见过的电子邮件的标题信息。
我在消息ID的循环中使用它。它为某些内容提供了正确的内容,并且在某些内容之后它返回空白。
for ($i = 0; $i < $unreadCounterGmail; $i++) {
$headers = imap_fetchheader($mbox, $unread[$i]);
echo "Loop counter = " . $i . " Message Number = " . $unread[$i] . " Header counter = " . count($headers) . "\n";
$subject = array();
$date = array();
$registrar = array();
preg_match_all('/^Subject: (.*)/m', $headers, $subject);
preg_match_all('/^Date: (.*)/m', $headers, $date);
preg_match_all('/^From: (.*)/m', $headers, $registrar);
$str = $subject[1][0];
$rgsmail = $registrar[1][0];
$receiveDate = $date[1][0];
echo "Reading FROM Gmail Acc :: Subject = " . $str . " :: From = " . $rgsmail . " :: Date = " . $receiveDate . " \n";
}