Get mail source using Zend_Mail
Asked Answered
N

4

8

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.

Nole answered 24/8, 2011 at 6:4 Comment(0)
R
2

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.

Reorganization answered 30/8, 2011 at 20:13 Comment(0)
B
1

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

Bluecoat answered 24/8, 2011 at 7:57 Comment(0)
I
1

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

/** @var $message Zend_Mail */
echo $message->getBodyText()->getRawContent();
Indiscernible answered 25/8, 2011 at 16:22 Comment(0)
A
1

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(); 
Anaemia answered 6/12, 2011 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.