我正在发送带有一些 xheader 的电子邮件。
当电子邮件的收件人重播该电子邮件时,我想解析它,并从我通过重播获得的邮件中获取该 xheader 的内容。
不幸的是,当我解析收到的电子邮件时,我没有看到我的 xheader。(我打印了整封电子邮件,xheader 不存在)
我如何在 PHP 中使用 Zend Framework(我使用 Zend_Mail_Storage_Imap)来做到这一点?
代码:
$mail = new Zend_Mail_Storage_Imap(array(
'host' => 'pop.gmail.com',
'user' => 'a@gmail.com',
'password' => 'a',
'ssl' => 'SSL'
));
$count = $mail->countMessages();
$message = $mail->getMessage($count);
print_r($message);
//go through the message
foreach(new RecursiveIteratorIterator($message) as $part){
echo '*****************<br/>';
print_r($part);
echo '<br/>*****************<br/>';
//match parts content type to text/html - the one that maches is the message HTML body
if (preg_match('/.*text\/html.*/', $part->contentType)){
$body = $part->getContent();
}
$headers = $part->getHeaders();
if (isset($headers['X-aHeader'])){
echo $headers['X-aHeader'];
}
谢谢,鲍里斯。