Fork of FusionPBX but with LDAP kinda working
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.5 KiB

2 years ago
  1. <?php
  2. /*
  3. * parse_message.php
  4. *
  5. * @(#) $Header: /home/mlemos/cvsroot/pop3/parse_message.php,v 1.4 2008/01/09 07:32:19 mlemos Exp $
  6. *
  7. */
  8. ?><html>
  9. <head>
  10. <title>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</title>
  11. </head>
  12. <body>
  13. <center><h1>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</h1></center>
  14. <hr />
  15. <?php
  16. require('mime_parser.php');
  17. require('rfc822_addresses.php');
  18. require('pop3.php');
  19. stream_wrapper_register('pop3', 'pop3_stream'); /* Register the pop3 stream handler class */
  20. $user=UrlEncode("");
  21. $password=UrlEncode("");
  22. $realm=UrlEncode(""); /* Authentication realm or domain */
  23. $workstation=UrlEncode(""); /* Workstation for NTLM authentication */
  24. $apop=0; /* Use APOP authentication */
  25. $authentication_mechanism=UrlEncode("USER"); /* SASL authentication mechanism */
  26. $debug=1; /* Output debug information */
  27. $html_debug=1; /* Debug information is in HTML */
  28. $message=1;
  29. $message_file='pop3://'.$user.':'.$password.'@localhost/'.$message.
  30. '?debug='.$debug.'&html_debug='.$html_debug.'&realm='.$realm.'&workstation='.$workstation.
  31. '&apop='.$apop.'&authentication_mechanism='.$authentication_mechanism;
  32. /*
  33. * Access Gmail POP account
  34. */
  35. /*
  36. $message_file='pop3://'.$user.':'.$password.'@pop.gmail.com:995/1?tls=1&debug=1&html_debug=1';
  37. */
  38. $mime=new mime_parser_class;
  39. /*
  40. * Set to 0 for not decoding the message bodies
  41. */
  42. $mime->decode_bodies = 1;
  43. $parameters=array(
  44. 'File'=>$message_file,
  45. /* Read a message from a string instead of a file */
  46. /* 'Data'=>'My message data string', */
  47. /* Save the message body parts to a directory */
  48. /* 'SaveBody'=>'/tmp', */
  49. /* Do not retrieve or save message body parts */
  50. 'SkipBody'=>1,
  51. );
  52. $success=$mime->Decode($parameters, $decoded);
  53. if(!$success)
  54. echo '<h2>MIME message decoding error: '.HtmlSpecialChars($mime->error)."</h2>\n";
  55. else
  56. {
  57. echo '<h2>MIME message decoding successful</h2>'."\n";
  58. echo '<h2>Message structure</h2>'."\n";
  59. echo '<pre>';
  60. var_dump($decoded[0]);
  61. echo '</pre>';
  62. if($mime->Analyze($decoded[0], $results))
  63. {
  64. echo '<h2>Message analysis</h2>'."\n";
  65. echo '<pre>';
  66. var_dump($results);
  67. echo '</pre>';
  68. }
  69. else
  70. echo 'MIME message analyse error: '.$mime->error."\n";
  71. }
  72. ?>
  73. <hr />
  74. </body>
  75. </html>