Location: PHPKode > projects > EXtensible Production Suite (XPS) > xpsdev/helpers/xpm3/EXAMPLES/pop3.php
<?php

/***************************************************************************************
 *                                                                                     *
 * This file is part of the XPertMailer package (http://xpertmailer.sourceforge.net/)  *
 *                                                                                     *
 * XPertMailer is free software; you can redistribute it and/or modify it under the    *
 * terms of the GNU General Public License as published by the Free Software           *
 * Foundation; either version 2 of the License, or (at your option) any later version. *
 *                                                                                     *
 * XPertMailer is distributed in the hope that it will be useful, but WITHOUT ANY      *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A     *
 * PARTICULAR PURPOSE.  See the GNU General Public License for more details.           *
 *                                                                                     *
 * You should have received a copy of the GNU General Public License along with        *
 * XPertMailer; if not, write to the Free Software Foundation, Inc., 51 Franklin St,   *
 * Fifth Floor, Boston, MA  02110-1301  USA                                            *
 *                                                                                     *
 * XPertMailer SMTP & POP3 PHP Mail Client. Can send and read messages in MIME Format. *
 * Copyright (C) 2006  Tanase Laurentiu Iulian                                         *
 *                                                                                     *
 ***************************************************************************************/

/**
 Receive an e-mail using a POP3 Mail Server (Gmail on port 995 via SSL)
 - show status about mailbox
 - if have messages, then show the last mail
*/

require_once '../XPM3_POP3.php';

// connect to POP3 mail server with username and password authentication via SSL
$conn = XPM3_POP3::Connect('pop.gmail.com', 'hide@address.com', 'password', 995, true) or die('Can not connect !');

/**
$recv = XPM3_POP3::Receive($conn);       // <- get all mesages
$recv = XPM3_POP3::Receive($conn, -1);   // <- get the last 1 mail
$recv = XPM3_POP3::Receive($conn, -2);   // <- get the lastest 2 mails
$recv = XPM3_POP3::Receive($conn, 0, 1); // <- get the old mail
// .. etc ... this function 'Receive()' works like 'substr()' order by old to last mail received
if ($recv) print_r($recv);
else echo 'message(s) not found';
*/

$stat = XPM3_POP3::pStat($conn) or die('STAT error !');
echo 'Messages: '.$stat[0].' in total: '.$stat[1].' Bytes.';
if ($stat[0] > 0) {
	// get the last mail
	if (!$retr = XPM3_POP3::pRetr($conn, $stat[0])) echo '<br />RETR error !';
	else echo '<br />The last mail received is:<br /><blockquote>'.nl2br(htmlentities($retr)).'</blockquote>';
} else echo '<br />MailBox is empty !';
// quit and close connection
XPM3_POP3::pQuit($conn);

?>
Return current item: EXtensible Production Suite (XPS)