PHP Classes

Parse body function

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Parse body function  >  (Un) Subscribe thread alerts  
Subject:Parse body function
Summary:How do I get just the body content without the headers
Messages:11
Author:emas
Date:2008-07-28 01:29:11
Update:2010-03-28 18:31:18
 
  1 - 10   11 - 11  

  1. Parse body function   Reply   Report abuse  
Picture of emas emas - 2008-07-28 01:29:11
Hi Manuel, thanks again for my last post.

I am using this code to get the text/html body.

$pop3->OpenMessage(1, -1);
$pop3->GetMessage(51024, $msg, $end_of_message);
var_dump($msg);

Below is the output.

...
IP Address: dd99.14.13.246 Date Modified: July 24, 2008, 8:45 am ------=_Part_9769_6352316.1217205107613 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Name: John Doe
Old email: [email protected]
------=_Part_9769_6352316.1217205107613-- "
...

Is there a way to just get this content below?

Name: John Doe
Old email: [email protected]


Thanks.

  2. Re: Parse body function   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-28 01:40:56 - In reply to message 1 from emas
If you pass the retrieved message to the MIME parser class, it can parse and extract the message body parts.

  3. Re: Parse body function   Reply   Report abuse  
Picture of emas emas - 2008-07-28 03:51:19 - In reply to message 2 from Manuel Lemos
Thanks, for the reply, Manuel.

I used the mime parser class but I cant see the body contents. Below var_dump($decoded[0])


["subject:"]=> string(7) "testing" ["mime-version:"]=> string(3) "1.0" ["content-type:"]=> string(71) "multipart/alternative; boundary="----=_Part_9769_6352316.1217205107613"" } ["Parts"]=> array(2) { [0]=> array(4) { ["Headers"]=> array(3) { ["content-type:"]=> string(30) "text/plain; charset=ISO-8859-1" ["content-transfer-encoding:"]=> string(4) "7bit" ["content-disposition:"]=> string(6) "inline" } ["Parts"]=> array(0) { } ["BodyPart"]=> int(1) ["BodyLength"]=> int(271) } [1]=> array(4) { ["Headers"]=> array(3) { ["content-type:"]=> string(29) "text/html; charset=ISO-8859-1" ["content-transfer-encoding:"]=> string(4) "7bit" ["content-disposition:"]=> string(6) "inline" } ["Parts"]=> array(0) { } ["BodyPart"]=> int(2) ["BodyLength"]=> int(776) } }


I only used the default parameter settings.

$mime->decode_bodies = 1;

$parameters=array(
'File'=>$message_file,

/* Read a message from a string instead of a file */
/*'Data'=>$email, */

/* Save the message body parts to a directory */
/* 'SaveBody'=>'/tmp', */

/* Do not retrieve or save message body parts */
'SkipBody'=>1,
);

Do I need to change one of the parameters? Or there a specific function under mime class to handle the body contents?


Thanks.

  4. Re: Parse body function   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-28 04:02:28 - In reply to message 3 from emas
That is because you have the SkipBody parameter in the array passed to the Decode function.

Just remove it and the class will return the body parts data as strings.

  5. Re: Parse body function   Reply   Report abuse  
Picture of emas emas - 2008-07-28 04:08:33 - In reply to message 4 from Manuel Lemos
hurrayyy for the second time!!!!. Sorry for the newbie questions. But this helps a lot for newbies like me.

  6. Re: Parse body function   Reply   Report abuse  
Picture of jangkukchol jangkukchol - 2008-07-29 07:54:19 - In reply to message 4 from Manuel Lemos
hi

I have enjoyed mime parser of your own making.
But one question here to await your kindness and time.

Does it support RFC 822 as well as RFC 2822?

Your reply would be appreciated.

thanks and regards

  7. Re: Parse body function   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-29 17:18:17 - In reply to message 6 from jangkukchol
RFC 2822 is a clarification of RFC 822. Despite some recomendations are deprecated, the class still handles them.

  8. Re: Parse body function   Reply   Report abuse  
Picture of john edwards john edwards - 2008-10-24 20:39:42 - In reply to message 2 from Manuel Lemos
Hello,

Is there a way to retrieve the html body part and the plain text body part separately? MIME parser class seems to return all the body parts in one big lump.

Thank you in advance.

  9. Re: Parse body function   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-10-25 00:52:22 - In reply to message 8 from john edwards
The class returns each part separately. If you get all parts together, maybe the message is not being passed to the class correctly. It is hard to tell without seeing how you are passing the message to the MIME parser class.

  10. Re: Parse body function   Reply   Report abuse  
Picture of Nikola Nikola - 2010-03-27 22:22:14 - In reply to message 9 from Manuel Lemos
Hy Manule,

At the begining sory for my bad english.
I have one problem: How to extraxt just a text from the body mail, In my case i have html signature in body mail and i must grab only text of mail without html signature of sender.

Thank you very mutch.

 
  1 - 10   11 - 11