|  | 
  alex ott - 2008-02-06 11:14:55hi,i use the pop class to open my mailbox and to get the headers of the messages - then i interate over the messages and decode them with yout mimedecoder class. one question: when get the headers with the RetrieveMessage method. the $header is an array.
 when i implode the array to a string (for the decode method, message input is  data, not file) with '\n', i get errors like: multipart/mixed is not supportet yet... when i implode it with '\n\r' it decodes, but after the method analyze the result is only:
 
 array(3) { ["Type"]=>  string(4) "text" ["Description"]=>  string(12) "Text message" ["DataFile"]=>  string(5) "tmp/1" }
 
 
 i know its a quastion between the two classes, but i hope you can help me.
 thnx
 alex
 
  alex ott - 2008-02-06 11:37:11 - In reply to message 1 from alex otthere is the code i wrote, maybe its easier to understand what i mean .-)
 
 <?
 
 require("pop3.php");
 require_once('rfc822_addresses.php');
 require_once('mime_parser.php');
 
 $pop3=new pop3_class;
 $pop3->hostname="mail.vvv.at";     /* POP 3 server host name                      */
 $pop3->port=110;                         /* POP 3 server host port,
 $pop3->tls=0;                           					 /* Establish secure connections using TLS      */
 $user="yyy";                        /* Authentication user name                    */
 $password="xxx";                    /* Authentication password                     */
 $pop3->realm="";                         /* Authentication realm or domain              */
 $pop3->workstation="";                   /* Workstation for NTLM authentication         */
 $apop=0;                                 /* Use APOP authentication                     */
 $pop3->authentication_mechanism="USER";  /* SASL authentication mechanism               */
 $pop3->debug=1;                          /* Output debug information                    */
 $pop3->html_debug=1;                     /* Debug information is in HTML                */
 $pop3->join_continuation_header_lines=1; /* Concatenate headers split in multiple lines */
 
 if(($error=$pop3->Open())==""){
 echo "<PRE>Connected to the POP3 server "".$pop3->hostname."".</PRE>\n";
 if(($error=$pop3->Login($user,$password,$apop))==""){
 echo "<li>$user logged in.";
 $result=$pop3->ListMessages("",1);
 if(is_array($result)){
 
 foreach($result as $key=>$value){
 echo("<hr><li><b>Number:$key  Unique ID:$value</b><br>");
 $pop3->RetrieveMessage($key,$header,$body,0);
 
 //Parse Header
 if(is_array($header)){
 $implodedheader = implode("\n",$header);
 
 $mime=new mime_parser_class;
 $mime->mbox = 1;
 $mime->decode_bodies = 0;
 $mime->decode_headers = 1;
 $mime->ignore_syntax_errors = 0;
 
 $parameters=array(
 //'File'=>$message_file,
 'Data'=>$implodedheader,
 /* Save the message body parts to a directory     */
 /*'SaveBody'=>'tmp', */
 /* Do not retrieve or save message body parts     */
 'SkipBody'=>0,
 );
 
 if(!$mime->Decode($parameters, $decoded)){
 echo 'MIME message decoding error: '.$mime->error.' at position '.$mime->error_position."\n";
 }else{
 echo 'MIME message decoding successful.'."\n";
 //var_dump($decoded[0]);
 if($mime->Analyze($decoded[0], $results)){
 echo("<li>Decoded Subject:".$results[Subject]."<br>");
 //var_dump($results);
 }else{
 echo 'MIME message analyse error: '.$mime->error."\n";
 }
 }
 }
 }
 }
 }
 if($error=="" && ($error=$pop3->Close())=="") echo "<li>Disconnected from the POP3 server "".$pop3->hostname."".</PRE>\n";
 }
 
 
 ?>
  Manuel Lemos - 2008-02-06 17:22:15 - In reply to message 2 from alex ottThe decode function needs the whole message to work properly. multipart/mixed messages are usually messages with attachments and the attachments are in the body.
 I suggest that you use the OpenMessage and GetMessage functions to retrieve the whole message with headers and body, or better, use the POP3 stream wrapper to pass a pop3:// URL to the MIME parser so it reads the whole message in small chunks at a time to parse the message properly.
  alex ott - 2008-02-07 10:58:15 - In reply to message 3 from Manuel Lemosthnx, stupid me .-)
 
 i will try it like you suggested.
 
  alex ott - 2008-02-07 12:08:13 - In reply to message 4 from alex ottis there any example for the OpenMessage and GetMessage functions to retrieve a message, i dont get it work...
  alex ott - 2008-02-07 13:12:31 - In reply to message 5 from alex ottgot it now.but there is still a problem.
 
 with openmessage and getmessage i get the whole message. but when i read out my mailbox (ex. 12 messages) in a foreach (array from listmessages) every second message will not be loaded (but without any errormessage). the message is null...
 
  alex ott - 2008-02-07 13:15:50 - In reply to message 5 from alex ottgot it now.but there is still a problem.
 
 with openmessage and getmessage i get the whole messages. but when i read out my mailbox (ex. 12 messages) in a foreach (array from listmessages) every second message is not loaded (but without any errors). the message is null...
 
  alex ott - 2008-02-07 13:40:12 - In reply to message 5 from alex ottok, i got it .-)
 but there is still a problem. when i read my mailbox, only every second mail is loaded with open/getmessage.
 can you find an error??:
 
 $result=$pop3->ListMessages("",0);
 if(is_array($result)){
 foreach($result as $number=>$size){
 echo("<hr><li><b>Number:$number  size:$size</b><br>");
 $pop3->OpenMessage($number,-1);
 $pop3->GetMessage($size,$msg,$eof);
 flush();
 if($msg) // PARSE ETC:
 }
 }
 
  alex ott - 2008-02-07 13:44:02 - In reply to message 3 from Manuel Lemosok, i got it .-)
 but there is still a problem. when i read my mailbox, only every second mail is loaded with open/getmessage.
 can you find an error?:
 
 $result=$pop3->ListMessages("",0);
 if(is_array($result)){
 foreach($result as $number=>$size){
 echo("<hr><li><b>Number:$number  size:$size</b><br>");
 $pop3->OpenMessage($number,-1);
 $pop3->GetMessage($size,$msg,$eof);
 flush();
 if($msg) // PARSE ETC:
 }
 }
 
  Manuel Lemos - 2008-02-07 14:11:28 - In reply to message 8 from alex ottYou need to call GetMessage repetedly while $eof is false. |