Ver Mensaje Individual
  #16 (permalink)  
Antiguo 09/03/2012, 13:19
ocp001a
Colaborador
 
Fecha de Ingreso: mayo-2008
Ubicación: $MX['VZ']['Xalapa']
Mensajes: 3.005
Antigüedad: 16 años
Puntos: 528
Respuesta: Sistema de Tickets como leer mails desde php cada cierto tiempo

Si bajaste la clase que te indiqué, en el mimo hay dos ejemplos, en el browse_mailbox.php tienes este código:

Código PHP:
Ver original
  1. <?php
  2. /*
  3.  * browse_mailbox.php
  4.  *
  5.  * @(#) $Header: /home/mlemos/cvsroot/pop3/browse_mailbox.php,v 1.1 2008/01/09 07:36:25 mlemos Exp $
  6.  *
  7.  */
  8.  
  9. ?><html>
  10. <head>
  11. <title>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</title>
  12. </head>
  13. <body>
  14. <center><h1>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</h1></center>
  15. <hr />
  16. <?php
  17.  
  18.     require('mime_parser.php');
  19.     require('rfc822_addresses.php');
  20.     require("pop3.php");
  21.  
  22.   /* Uncomment when using SASL authentication mechanisms */
  23.     /*
  24.     require("sasl.php");
  25.     */
  26.  
  27.     stream_wrapper_register('pop3', 'pop3_stream');  /* Register the pop3 stream handler class */
  28.  
  29.     $pop3=new pop3_class;
  30.     $pop3->hostname="localhost";             /* POP 3 server host name                      */
  31.     $pop3->port=110;                         /* POP 3 server host port,
  32.                                                 usually 110 but some servers use other ports
  33.                                                 Gmail uses 995                              */
  34.     $pop3->tls=0;                            /* Establish secure connections using TLS      */
  35.     $user="username";                        /* Authentication user name                    */
  36.     $password="password";                    /* Authentication password                     */
  37.     $pop3->realm="";                         /* Authentication realm or domain              */
  38.     $pop3->workstation="";                   /* Workstation for NTLM authentication         */
  39.     $apop=0;                                 /* Use APOP authentication                     */
  40.     $pop3->authentication_mechanism="USER";  /* SASL authentication mechanism               */
  41.     $pop3->debug=1;                          /* Output debug information                    */
  42.     $pop3->html_debug=1;                     /* Debug information is in HTML                */
  43.     $pop3->join_continuation_header_lines=1; /* Concatenate headers split in multiple lines */
  44.  
  45.     if(($error=$pop3->Open())=="")
  46.     {
  47.         echo "<PRE>Connected to the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
  48.         if(($error=$pop3->Login($user,$password,$apop))=="")
  49.         {
  50.             echo "<PRE>User &quot;$user&quot; logged in.</PRE>\n";
  51.             if(($error=$pop3->Statistics($messages,$size))=="")
  52.             {
  53.                 echo "<PRE>There are $messages messages in the mail box with a total of $size bytes.</PRE>\n";
  54.                 if($messages>0)
  55.                 {
  56.                     $pop3->GetConnectionName($connection_name);
  57.                     $message=1;
  58.                     $message_file='pop3://'.$connection_name.'/'.$message;
  59.                     $mime=new mime_parser_class;
  60.  
  61.                     /*
  62.                     * Set to 0 for not decoding the message bodies
  63.                     */
  64.                     $mime->decode_bodies = 1;
  65.  
  66.                     $parameters=array(
  67.                         'File'=>$message_file,
  68.  
  69.                         /* Read a message from a string instead of a file */
  70.                         /* 'Data'=>'My message data string',              */
  71.  
  72.                         /* Save the message body parts to a directory     */
  73.                         /* 'SaveBody'=>'/tmp',                            */
  74.  
  75.                         /* Do not retrieve or save message body parts     */
  76.                             'SkipBody'=>1,
  77.                     );
  78.                     $success=$mime->Decode($parameters, $decoded);
  79.  
  80.  
  81.                     if(!$success)
  82.                         echo '<h2>MIME message decoding error: '.HtmlSpecialChars($mime->error)."</h2>\n";
  83.                     else
  84.                     {
  85.                         echo '<h2>MIME message decoding successful</h2>'."\n";
  86.                         echo '<h2>Message structure</h2>'."\n";
  87.                         echo '<pre>';
  88.                         var_dump($decoded[0]);
  89.                         echo '</pre>';
  90.                         if($mime->Analyze($decoded[0], $results))
  91.                         {
  92.                             echo '<h2>Message analysis</h2>'."\n";
  93.                             echo '<pre>';
  94.                             var_dump($results);
  95.                             echo '</pre>';
  96.                         }
  97.                         else
  98.                             echo 'MIME message analyse error: '.$mime->error."\n";
  99.                     }
  100.                 }
  101.                 if($error==""
  102.                 && ($error=$pop3->Close())=="")
  103.                     echo "<PRE>Disconnected from the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
  104.             }
  105.         }
  106.     }
  107.     if($error!="")
  108.         echo "<H2>Error: ",HtmlSpecialChars($error),"</H2>";
  109. ?>
  110.  
  111. </body>
  112. </html>

Que si lo ejecutas, verás que el mensaje queda dentro de $results, y en el test le hace un vardump, donde puedes ver la estructura del email, y por tanto saber cómo obtener lo que necesitas. No puede ser más sencillo.