PHP Classes

How to get the HTML (pr plain text) body of the message

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  How to get the HTML (pr plain text)...  >  (Un) Subscribe thread alerts  
Subject:How to get the HTML (pr plain text)...
Summary:How to get the HTML (pr plain text) body of the message
Messages:4
Author:Alex V
Date:2011-09-23 14:06:44
Update:2011-09-26 22:09:02
 

  1. How to get the HTML (pr plain text)...   Reply   Report abuse  
Picture of Alex V Alex V - 2011-09-23 14:06:44
Is there an easy way to get the body of the message? I need to get the HTML content when available, plain text otherwise.

So far I do it this way for HTML:
$parser = new Core_MimeParser();
$parser->Decode(array('Data' => $msgSource), $decoded);

print_r($decoded[0]['Parts'][0]['Parts'][1]['Body']);

but I guess [0]['Parts'][0]['Parts'][1]['Body'] is not always there for plain text message?

  2. Re: How to get the HTML (pr plain text)...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2011-09-23 19:31:41 - In reply to message 1 from Alex V
The easiest way is to use also the Analyze function after having used the Decode function as demonstrated in the example scripts.

  3. Re: How to get the HTML (pr plain text)...   Reply   Report abuse  
Picture of Alex V Alex V - 2011-09-26 20:17:00 - In reply to message 2 from Manuel Lemos
But as far as I can see, the Analyze() function dosen't contain the body of the message...

  4. Re: How to get the HTML (pr plain text)...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2011-09-26 22:09:02 - In reply to message 3 from Alex V
The Analyze function returns the body message if it was passed to it. So if you do not use the SkipBody option in the Decode function, the Analyze function returns the same body data returned by the Decode function.