Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

POP3-Example

Sections:

Example Code:

The following code demonstrates how to use the class.

<?php
/*!***********************************************************************
 *************************************************************************
 * \file            pop3-sample.php
 *
 * \author          Kai Klenovsek
 *
 * \date            First Step: 2004-12-27 <br>
 *
 * \note <br>
 * \b THE \bBEER-WARE \bLICENSE <br>
 *    As long as you retain this notice you can do whatever you want with <br>
 *    this stuff. If we meet some day, and you think this stuff is worth it, <br>
 *    you can buy me a beer in return. <br>
 *
 * \b NOTES: <br>
 * 
***************************************************************************
***************************************************************************/
  
// Include phplibex
require("../../phplibex.inc.php");
    
// Create mail object
$mail = new pop3();

/* Connect to POP3 server */
if ( $mail->pop3_connect("localhost", "newuser", "wampp", 20) )
{
    /* Get mailbox info array. 
     * Every array element includes the mail ID and the size in byte */
    $data = $mail->pop3_get_mailbox_info();
    echo "<b>Mailbox info: </b><br>";
    
    for ( $loop=0; $loop<=sizeof($data)-1; $loop++ )
        echo "Mail ID and Size: ".$data[$loop]."<br>";    
       
 
    /* Get mail unique array. 
     * Every array element includes the mail ID with unique key. */
    $data = $mail->pop3_get_mail_keys();
    echo "<br><b>Mail unique keys: </b><br>";
    
    for ( $loop=0; $loop<=sizeof($data)-1; $loop++ )
        echo "Mail ID and Unique key: ".$data[$loop]."<br>";   
    
    // Get single mail unique key
    echo "<br><b>Single Mail Unique key: </b>".$mail->pop3_get_mail_key(2)."<br><br>";
    
    // Get single mail info string with ID 1 
    echo "<b>Mail single info: </b>".$mail->pop3_get_mail_info(1)."<br><br>";

    // Get single mail size
    echo "<b>Single mail size: </b>".$mail->pop3_get_mail_size(1)."<br><br>";

    // Get mail with ID 1
    echo "<b>Mail data: </b><br>".$mail->pop3_get_mail(1)."<br><br>";
}
else
    echo "Connection to server NOT established !!";


// Close connection to POP3 server
$mail->pop3_close();

// Get the complete pop3 stream
$stream = $mail->pop3_get_stream();

// Show pop3 stream
echo "<br><br><b>Stream:</b><br>";
for ( $loop=0; $loop <= sizeof($stream); $loop++ )
    echo $stream[$loop]."<br>";    

// Get error list
$error = $mail->pop3_get_errorlist();

// Show errors
echo "<br><b>Errorlist:</b><br>";  
for ( $loop=0; $loop <= sizeof($error); $loop++ )
    echo $error[$loop]."<br>";    

?>

Related Links:

POP3 RFC: http://www.rfc-editor.org/rfc/rfc1939.txt
Generated on Fri Aug 26 08:13:54 2005 for PHP-Lib-Xtreme by  doxygen 1.4.3