PHP Classes

MIME message decoding

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  MIME message decoding  >  (Un) Subscribe thread alerts  
Subject:MIME message decoding
Summary:MIME message decoding error: reached a premature end of data.
Messages:2
Author:Petar
Date:2007-09-26 05:48:39
Update:2007-09-27 01:06:52
 

  1. MIME message decoding   Reply   Report abuse  
Picture of Petar Petar - 2007-09-26 05:48:39
Hi

This is a short example:

$pop3->Open();
$pop3->Login($user,$password,$apop);
$pop3->Statistics($messages,$size);
if($messages>0) { for each message -->
$pop3->OpenMessage(MsgNo);
do {$error=$pop3->GetMessage(512, $msg, $end_of_message);}
while(!$end_of_message);
$parameters=array('Data'=>$msg);
$success=$mime->Decode($parameters, $decoded);
}

It works GREAT for every plain tex message in mailbox.

There is a problem with MIME-Version: 1.0 Content-Type: multipart/mixed and multipart/alternative messages.

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

Any suggestions?

Thanks

  2. Re: MIME message decoding   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-09-27 01:06:52 - In reply to message 1 from Petar
It seems you are not concatenating the chunk of the message that you retrieve with GetMessage function. Try this in the retrieval loop:

$msg='';
do
{
if(strlen($error=$pop3->GetMessage(512, $chunk, $end_of_message))
die($error);
$msg.=$chunk;
}
while(!$end_of_message);