Namida - 2007-12-10 04:55:51 -
In reply to message 4 from Manuel Lemos
First things first, kuddos to Mr. Lemos for this SUPERB class ;)
Now on to bussiness...
Here's a little code that might get you going, first copy/paste the example code at tet_pop3.php and after it gets the Statistics (line #46) replace the ENTIRE if (up to line #89) with this...
$id = 1 // id of the message to read
if(($error=$pop3->OpenMessage($id,-1))=="")
{
$eml_file = time() . "_" . uniqid() . ".eml"; //output file name
$file_handler = fopen($eml_file, 'wb') or die("can't open file");
while(!$eof)
{
if(($error=$pop3->GetMessage(100000,$data,$eof))=="");
else $eof = true;
fwrite($file_handler,$data);
}
fclose($file_handler);
}
this way you read the message and output it into a file ($eml_file).
I almost forgot, notice that
else $eof = true;
the thing is, if you get an error while reading the message, you'll have a broken file, so that else will break the while statement (I'm not sure, but, most likely, GetMessage returns $eof=true upon error, I should try that...), so now the only thing left is to unlink the broken file, so in the
if($error!="") at the end of the example you should add...
if(isset($eml_file)) unlink($eml_file);
and that's it ;)
it worked for me, hope anyone finds it useful!