Xataface Email Module  0.3.2
Email/Mailmerge Module for Xataface
 All Data Structures Files Functions Variables Pages
pop3-read.php
Go to the documentation of this file.
1 <?php
2 
3 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4  * *
5  * XPertMailer is a PHP Mail Class that can send and read messages in MIME format. *
6  * This file is part of the XPertMailer package (http://xpertmailer.sourceforge.net/) *
7  * Copyright (C) 2007 Tanase Laurentiu Iulian *
8  * *
9  * This library is free software; you can redistribute it and/or modify it under the *
10  * terms of the GNU Lesser General Public License as published by the Free Software *
11  * Foundation; either version 2.1 of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY *
14  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
15  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Lesser General Public License along with *
18  * this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
19  * Fifth Floor, Boston, MA 02110-1301, USA *
20  * *
21  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
22 
23 /* Purpose:
24  - connect to POP3 server (Gmail) via SSL (SSL encryption)
25  - print the source of last mail message
26 */
27 
28 // manage errors
29 error_reporting(E_ALL); // php errors
30 define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
31 
32 // path to 'POP3.php' file from XPM4 package
33 require_once '../POP3.php';
34 
35 // connect to POP3 server via SSL (SSL encryption) with authentication on port '995' and timeout '10' secounds
36 // make sure you have OpenSSL module (extension) enable on your php configuration
37 $c = POP3::connect('pop.gmail.com', 'username@gmail.com', 'password', 995, 'ssl', 10) or die(print_r($_RESULT));
38 // STAT
39 $s = POP3::pStat($c) or die(print_r($_RESULT));
40 // $i - total number of messages, $b - total bytes
41 list($i, $b) = each($s);
42 if ($i > 0) { // if we have messages
43  // RETR
44  $r = POP3::pRetr($c, $i) or die(print_r($_RESULT)); // <- get the last mail (newest)
45  // or pRetr($c, 1) <- get the old mail
46  // print the source of message
47  echo $r;
48  // optional, you can delete this message from server
49  POP3::pDele($c, $i) or die(print_r($_RESULT));
50 } else echo 'MailBox is empty !';
51 // disconnect
52 POP3::disconnect($c);
53 
54 ?>