Location: PHPKode > scripts > XS PHP Library > xs-php-library/src/pop3.php
<?php
//
// +--------------------------------------------------------------------------+
// |                                                                          |
// |                   XS PHP Library  Generic Classes Library                |
// |                                                                          |
// |                   Copyright (c) 2001-2002 XSPHPLib Group.                |
// |                                                                          |
// +--------------------------------------------------------------------------+
// |                                                                          |
// | Distributed under the terms of the GNU Lesser General Public License as  |
// | published by the Free Software Foundation version 2.1                    |
// | See the GNU Lesser General Public License for more details. You should   |
// | have received a copy of the GNU Lesser General Public License along with |
// | this package; if not, write to the Free Software Foundation, Inc.,       |
// | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.                 |
// |                                                                          |
// +--------------------------------------------------------------------------+
// |                                                                          |
// | Authors: Robert Bala <hide@address.com>                                   |
// |                                                                          |
// +--------------------------------------------------------------------------+
//
// $Id: pop3.php,v 1.2 2002/11/28 09:51:38 rbala Exp $

include_once('../inc/object.inc.php');
include_once('../inc/socket.inc.php');
include_once('../inc/pop3.inc.php');
include_once('../inc/mime.inc.php');
include_once('../inc/mail.inc.php');

$host = 'localhost';
$user = 'username';
$pass = 'password';

$pop3 = new POP3($host);

object_checkError($pop3->open());

object_checkError($pop3->auth($user, $pass));

$result = $pop3->lst();

if (object_isError($result)) {
    die($result->getMessage());
}

echo 'Message List:<br>';

foreach ($result as $info) {
    echo 'index: ' . $info[0] . ' octets: ' . $info[1] . '<br>';
}

echo '<p><b>Raw message content:</b></p>';

$result = $pop3->retr(1);

if (object_isError($result)) {
    die($result->getMessage());
}

echo '<pre>';
echo $result;
echo '</pre>';

$mail = new Mail();

$mail->parseMessage($result);

echo '<p><b>Parsed message content:</b></p>';

echo '<pre>';
echo $mail->getContent();
echo '</pre>';

object_checkError($pop3->close());

?>
Return current item: XS PHP Library