Sfisioza
Sfisioza

Reputation: 3930

Get mail source using Zend_Mail

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.

Upvotes: 8

Views: 1973

Answers (4)

Petr Kovar
Petr Kovar

Reputation: 11

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(); 

Upvotes: 1

takeshin
takeshin

Reputation: 50638

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.

Upvotes: 2

Maxence
Maxence

Reputation: 13296

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

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

Upvotes: 1

dinopmi
dinopmi

Reputation: 2673

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

Upvotes: 1

Related Questions