2011-04-04 35 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