2011-04-04 112 views
1

我使用Zend Mail来获取我的POP3服务器中的电子邮件列表,并将其显示在网页上。这里是我的代码:Zend邮件内容

<? 

require("Zend/Mail/Storage/Pop3.php"); 

$mail = new Zend_Mail_Storage_Pop3(array('host'  => 'localhost', 
             'user'  => 'person', 
             'password' => 'awesome')); 

// show the mail! 

echo "You have " . $mail->countMessages() . " messages! <br><br>"; 

foreach ($mail as $message) { 
    echo "From: '{$message->from}'<br> Subject: {$message->subject}<br>"; 
    echo "Content: " . $message->getContent() . "<br><br>"; 
} 

?> 

的问题是,一些email都出现了这样的:

From: 'Trey ' 
Subject: WOMBATS WOMBATS 
Content: --Apple-Mail-1--609821059 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii SWIMMING IN THE OCEAN CAUSIN' A COMOTION CUZ THEY SUCK --Apple-Mail-1--609821059 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii SWIMMING IN THE OCEAN 
CAUSIN' A COMOTION 
CUZ THEY 
SUCK 
--Apple-Mail-1--609821059-- 

这使得它难以阅读邮件的实际主体内容。我想让它看起来像这样:

From: 'Stan Flusterflap ' 
Subject: hi 
Content: hi 

我该如何去做这件事?谢谢。

+3

你可能想要做一些有关整个袋熊虫感染的事情。 – Charles 2011-04-04 05:15:07

回答

3

getContent方法获取整个消息正文。你看到的是整个主体,由两个MIME部分及其分隔符组成。

There's an example in the manual - 搜索“多部分” - 如何直接使用the MIME parts

+0

对。你也许可以看看http://stackoverflow.com/questions/2749772/cant-get-message-body-of-certain-emails-from-inbox-using-the-zend-framework – 2011-04-04 05:19:24