home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Net_POP3_example.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  4.0 KB  |  129 lines

  1. <?php
  2. // +-----------------------------------------------------------------------+
  3. // | Copyright (c) 2002, Richard Heyes                                     |
  4. // | All rights reserved.                                                  |
  5. // |                                                                       |
  6. // | Redistribution and use in source and binary forms, with or without    |
  7. // | modification, are permitted provided that the following conditions    |
  8. // | are met:                                                              |
  9. // |                                                                       |
  10. // | o Redistributions of source code must retain the above copyright      |
  11. // |   notice, this list of conditions and the following disclaimer.       |
  12. // | o Redistributions in binary form must reproduce the above copyright   |
  13. // |   notice, this list of conditions and the following disclaimer in the |
  14. // |   documentation and/or other materials provided with the distribution.|
  15. // | o The names of the authors may not be used to endorse or promote      |
  16. // |   products derived from this software without specific prior written  |
  17. // |   permission.                                                         |
  18. // |                                                                       |
  19. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
  20. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
  21. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
  22. // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
  23. // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
  24. // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
  25. // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
  26. // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
  27. // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
  28. // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
  29. // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
  30. // |                                                                       |
  31. // +-----------------------------------------------------------------------+
  32. // | Author: Richard Heyes <richard@phpguru.org>                           |
  33. // +-----------------------------------------------------------------------+
  34. //
  35. // $Id: Net_POP3_example.php,v 1.2 2002/07/27 13:07:55 richard Exp $
  36. ?>
  37. <html>
  38. <body>
  39. <?php
  40.  
  41. include('Net/POP3.php');
  42.  
  43.  
  44.  
  45. $user='richard';
  46. $pass='Alien3';
  47. $host='localhost';
  48. $port="110";
  49.  
  50. // you can create a file called passwords.php and store your $user,$pass,$host and $port values in it
  51. // or you can modify this script
  52. @include_once("./passwords.php");
  53.  
  54.  
  55.  
  56. // Create the class
  57.  
  58. $pop3 =& new Net_POP3();
  59.  
  60.  
  61. $pop3->setDebug();
  62.  
  63. // Connect to localhost on usual port
  64. // If not given, defaults are localhost:110
  65.  
  66. $pop3->connect($host , $port );
  67.  
  68.  
  69. // Login using username/password. APOP will
  70. // be tried first if supported, then basic.
  71.  
  72. //$pop3->login($user , $pass , 'APOP');
  73. //$pop3->login($user , $pass , 'CRAM-MD5');
  74. $pop3->login($user , $pass );
  75.  
  76.  
  77. // Get the raw headers of message 1
  78.  
  79. echo "<h2>getRawHeaders()</h2>\n";
  80. echo "<pre>" . htmlspecialchars($pop3->getRawHeaders(1)) . "</pre>\n";
  81.  
  82.  
  83. // Get structured headers of message 1
  84.  
  85. echo "<h2>getParsedHeaders()</h2> <pre>\n";
  86. print_r($pop3->getParsedHeaders(1));
  87. echo "</pre>\n";
  88.  
  89.  
  90. // Get body of message 1
  91.  
  92. echo "<h2>getBody()</h2>\n";
  93. echo "<pre>" . htmlspecialchars($pop3->getBody(1)) . "</pre>\n";
  94.  
  95.  
  96. // Get number of messages in maildrop
  97.  
  98. echo "<h2>getNumMsg</h2>\n";
  99. echo "<pre>" . $pop3->numMsg() . "</pre>\n";
  100.  
  101.  
  102. // Get entire message
  103.  
  104. echo "<h2>getMsg()</h2>\n";
  105. echo "<pre>" . htmlspecialchars($pop3->getMsg(1)) . "</pre>\n";
  106.  
  107.  
  108.  
  109.  
  110.  
  111. // Get listing details of the maildrop
  112.  
  113. echo "<h2>getListing()</h2>\n";
  114. echo "<pre>\n";
  115. print_r($pop3->getListing());
  116. echo "</pre>\n";
  117.  
  118.  
  119. // Get size of maildrop
  120.  
  121. echo "<h2>getSize()</h2>\n";
  122. echo "<pre>" . $pop3->getSize() . "</pre>\n";
  123.  
  124.  
  125. // Disconnect
  126.  
  127. $pop3->disconnect();
  128. ?>
  129.