使用 Zend_Mail 获取邮件源

发布于 2024-12-01 06:17:05 字数 85 浏览 9 评论 0原文

如何使用 Zend_Mail (POP3) 获取邮件源(标头、正文、边界 - 全部作为纯文本)。

它默认返回已解析的部分,我需要原始消息源。

How can I get mail source (headers, body, boundary - all together as a plain text) using Zend_Mail (POP3).

It returns parsed parts by default, I need the raw message source.

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

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

发布评论

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

评论(4

知足的幸福 2024-12-08 06:17:05

Zend Mail 中没有这样的方法。

但是您可以查看类源并了解如何向邮件服务器发送直接命令以获取消息源。

There's no such method in Zend Mail.

But you may look at the class sources and see how to send a direct command to the mail server to get the message source.

新一帅帅 2024-12-08 06:17:05

也许您可以使用 Zend_Mail_Storage_Pop3 类的 getRawHeader()getRawContent() 方法。这足以满足您的目的吗?

一些 API 文档(我在参考指南中没有找到它们) ):

Maybe you could use the getRawHeader() and getRawContent() methods of the Zend_Mail_Storage_Pop3 class. Would it be enough for your purpose?

Some API docs (I didn't find them in the Reference Guide):

自由如风 2024-12-08 06:17:05

如果你有 Zend_Mail 实例,你可以获得解码后的内容:

/** @var $message Zend_Mail */
echo $message->getBodyText()->getRawContent();

If you have a Zend_Mail instance, you can get the decoded content:

/** @var $message Zend_Mail */
echo $message->getBodyText()->getRawContent();
无所谓啦 2024-12-08 06:17:05

我为此创建了自己的图层:

    /**
 * Transport mail layer for retrieve content of message
 *
 * @author Petr Kovar
 */
class My_Mailing_Transport extends Zend_Mail_Transport_Abstract{

    protected $_messageContent;

    /**
     * Only assign message to some variable
     */
    protected function _sendMail(){

        $this->_messageContent = $this->header . Zend_Mime::LINEEND . $this->body;
    }

    /**
     * Get source code of message
     * 
     * @return string
     */
    public function getMessageContent(){
        return $this->_messageContent;
    }

}

而不只是调用它:

$transport = new My_Mailing_Transport();
$transport->send($mail);
return $transport->getMessageContent(); 

I made my own layer for that:

    /**
 * Transport mail layer for retrieve content of message
 *
 * @author Petr Kovar
 */
class My_Mailing_Transport extends Zend_Mail_Transport_Abstract{

    protected $_messageContent;

    /**
     * Only assign message to some variable
     */
    protected function _sendMail(){

        $this->_messageContent = $this->header . Zend_Mime::LINEEND . $this->body;
    }

    /**
     * Get source code of message
     * 
     * @return string
     */
    public function getMessageContent(){
        return $this->_messageContent;
    }

}

And than only call that:

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