Xataface Email Module 0.2
Email/Mailmerge Module for Xataface
lib/XPM/EXAMPLES/pop3-read.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  *                                                                                         *
00005  *  XPertMailer is a PHP Mail Class that can send and read messages in MIME format.        *
00006  *  This file is part of the XPertMailer package (http://xpertmailer.sourceforge.net/)     *
00007  *  Copyright (C) 2007 Tanase Laurentiu Iulian                                             *
00008  *                                                                                         *
00009  *  This library is free software; you can redistribute it and/or modify it under the      *
00010  *  terms of the GNU Lesser General Public License as published by the Free Software       *
00011  *  Foundation; either version 2.1 of the License, or (at your option) any later version.  *
00012  *                                                                                         *
00013  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY        *
00014  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A        *
00015  *  PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.        *
00016  *                                                                                         *
00017  *  You should have received a copy of the GNU Lesser General Public License along with    *
00018  *  this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
00019  *  Fifth Floor, Boston, MA 02110-1301, USA                                                *
00020  *                                                                                         *
00021  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00022 
00023 /* Purpose:
00024    - connect to POP3 server (Gmail) via SSL (SSL encryption)
00025    - print the source of last mail message
00026 */
00027 
00028 // manage errors
00029 error_reporting(E_ALL); // php errors
00030 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
00031 
00032 // path to 'POP3.php' file from XPM4 package
00033 require_once '../POP3.php';
00034 
00035 // connect to POP3 server via SSL (SSL encryption) with authentication on port '995' and timeout '10' secounds
00036 // make sure you have OpenSSL module (extension) enable on your php configuration
00037 $c = POP3::connect('pop.gmail.com', 'username@gmail.com', 'password', 995, 'ssl', 10) or die(print_r($_RESULT));
00038 // STAT
00039 $s = POP3::pStat($c) or die(print_r($_RESULT));
00040 // $i - total number of messages, $b - total bytes
00041 list($i, $b) = each($s);
00042 if ($i > 0) { // if we have messages
00043         // RETR
00044         $r = POP3::pRetr($c, $i) or die(print_r($_RESULT)); // <- get the last mail (newest)
00045         // or pRetr($c, 1) <- get the old mail
00046         // print the source of message
00047         echo $r;
00048         // optional, you can delete this message from server
00049         POP3::pDele($c, $i) or die(print_r($_RESULT));
00050 } else echo 'MailBox is empty !';
00051 // disconnect
00052 POP3::disconnect($c);
00053 
00054 ?>
 All Data Structures Files Functions Variables Enumerations