PHP Classes

What is the way of decoding a single email?

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  What is the way of decoding a single...  >  (Un) Subscribe thread alerts  
Subject:What is the way of decoding a single...
Summary:Single email saved to disk only has 13 bytes. </MESSAGE>
Messages:6
Author:Ramiro Banda
Date:2007-10-10 00:43:39
Update:2007-10-11 06:43:41
 

  1. What is the way of decoding a single...   Reply   Report abuse  
Picture of Ramiro Banda Ramiro Banda - 2007-10-10 00:43:39
Hello,

I tested the class decoding multipart messages with a SMTP client for PHP, and works fine, i sended several emails using Outlook, but when i use a basic message of hotmail for example who isn't multipart and if i set

$mime->mbox = 0;// or 1 i get the same,

At the end of parsing a single email, this is saved at disk with only 13 bytes:

</MESSAGE>

What i'am doing wrong?
i would like to open the file "1" created, but is doesn't have the body.



  2. Aditional information   Reply   Report abuse  
Picture of Ramiro Banda Ramiro Banda - 2007-10-10 01:15:57 - In reply to message 1 from Ramiro Banda
i'am geting the error in the decoded file without real data also when i use multipart format.

The email sended from hotmail by Outlook Express to my SMTP account is decoded, but sending the email using the web(www.hotmail.com),the text isn't decoded and saved correclty.I'am using:


$parameters=array(
'Data'=>$the_email,//a string with email data from SMTP client
'SaveBody'=>'upload',
'SkipBody'=>0,
);

if(!$mime->Decode($parameters, $decoded))

In short, somebody experienced this error(an email decoded and saved with only: "</MESSAGE> "), when the incoming email is www.hotmail?

thanks,

  3. Re: What is the way of decoding a single...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-10-10 01:22:22 - In reply to message 1 from Ramiro Banda
This is very confusing.

A valid message must have a set of header lines, an empty line and the rest of the message lines is the body.

What exactly is the message data that you are passing to the class?

  4. Re: What is the way of decoding a single...   Reply   Report abuse  
Picture of Ramiro Banda Ramiro Banda - 2007-10-10 16:25:12 - In reply to message 3 from Manuel Lemos
Hello Manuel thanks for your response, yes my email is a bit confussing and i will try to explain it better.

First i'am using Class pop3.class.inc and the output feeds to your class, decoding works fine with atachments and emails with html(when is included an alternate text thanks to Outlook Express)

But I'am getting the error:

"MIME message decoding error: reached a premature end of data at position -1"

when the incoming email is ONLY text or ONLY html.

Here is the "exact" email in text/plain who gives error:

librosdorados.com/files/hotmail_err ...

the body is: "probando."

Here the email with text/plain and text/html, who is decoded without errors:

librosdorados.com/files/hotmail_dec ...

The body: "This email has html but also with txt."


In both cases i'am using Outlook,sending an email from my hotmail to my smtp accout, in the first case the email is text and in the second is html).

I'am thinking that the error happens because the start of body isn't defined properly after of the empty line.

If decoding of basic messages(only html or txt) works fine perhaps the class Class pop3.class.inc that i'am using, has bugs?

Thanks in advance,

  5. Re: What is the way of decoding a single...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-10-10 18:00:30 - In reply to message 4 from Ramiro Banda
I don't know who inserted those marks </HEADER> and <MESSAGE> but they should not be there. There should be an empty line between headers and the body message.

If those marks are inserted by the POP3 class you are using, you need to remove them or use this other POP3 class that even comes with an example to parse retrieved messages with the MIME parser class:

phpclasses.org/pop3class

  6. Re: What is the way of decoding a single...   Reply   Report abuse  
Picture of Ramiro Banda Ramiro Banda - 2007-10-11 06:43:41 - In reply to message 5 from Manuel Lemos
I deleted labels </HEADER> and <MESSAGE>, inside this class, and inserted "\n\r" and now everything is working as expected(i didn't find an error yet), was not required to change of class.

Thanks so much Manuel!

Ramiro Banda