Zend Mail 消息内容

发布于 2024-10-30 19:29:34 字数 1223 浏览 1 评论 0原文

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

<?

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>";
}

?>

问题是某些电子邮件显示如下:

    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 

我将如何去做呢?谢谢。

I am using Zend Mail in order to get a list of email messages from my POP3 server, and display it on a web page. Here is my code:

<?

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>";
}

?>

The problem is that some of the emails are showing up like this:

    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-- 

which makes it hard to read the actual body content of the message. I want it to show up like this:

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

How would I go about doing this? Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许久 2024-11-06 19:29:34

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

手册中有一个示例 -- 搜索“multipart part” " -- 如何直接使用 MIME 部分

The getContent method gets the entire message body. What you're seeing there is the entire body, composed of two MIME parts and their separators.

There's an example in the manual -- search for "multipart part" -- of how to work with the MIME parts directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文