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.

Sfisioza
  • 3,830
  • 6
  • 42
  • 57

4 Answers4

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.

takeshin
  • 49,108
  • 32
  • 120
  • 164
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):

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
dinopmi
  • 2,683
  • 19
  • 24
1

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

/** @var $message Zend_Mail */
echo $message->getBodyText()->getRawContent();
Maxence
  • 12,868
  • 5
  • 57
  • 69
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(); 
Petr Kovar
  • 11
  • 2