Get mail source using Zend_Mail

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

It returns the processed parts by default, I need the source of the original message.

+7
source share
4 answers

There is no such method in Zend Mail.

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

+2
source

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

Some API docs (I did not find them in the Reference Guide):

+1
source

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

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

I made my own layer for this:

  /** * 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 just call it:

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

All Articles