Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
// +-----------------------------------------------------------------------+
3
// | Copyright (c) 2002, Richard Heyes                                     |
4
// | All rights reserved.                                                  |
5
// |                                                                       |
6
// | Redistribution and use in source and binary forms, with or without    |
7
// | modification, are permitted provided that the following conditions    |
8
// | are met:                                                              |
9
// |                                                                       |
10
// | o Redistributions of source code must retain the above copyright      |
11
// |   notice, this list of conditions and the following disclaimer.       |
12
// | o Redistributions in binary form must reproduce the above copyright   |
13
// |   notice, this list of conditions and the following disclaimer in the |
14
// |   documentation and/or other materials provided with the distribution.|
15
// | o The names of the authors may not be used to endorse or promote      |
16
// |   products derived from this software without specific prior written  |
17
// |   permission.                                                         |
18
// |                                                                       |
19
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
20
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
21
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
22
// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
23
// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
24
// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
25
// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26
// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27
// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
28
// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29
// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
30
// |                                                                       |
31
// +-----------------------------------------------------------------------+
32
// | Author: Richard Heyes <richard@phpguru.org>                           |
33
// | Co-Author: Damian Fernandez Sosa <damlists@cnba.uba.ar>               |
34
// +-----------------------------------------------------------------------+
35
//
36
// $Id: Net_POP3_example.php 232723 2007-03-27 12:16:28Z cweiske $
37
?>
38
<html>
39
<body>
40
<?php
41
 
42
include_once 'Net/POP3.php';
43
 
44
 
45
 
46
 
47
$user='richard';
48
$pass='Alien3';
49
$host='localhost';
50
$port="110";
51
 
52
// you can create a file called passwords.php and store your $user,$pass,$host and $port values in it
53
// or you can modify this script
54
@include_once("./passwords.php");
55
 
56
 
57
 
58
// Create the class
59
 
60
$pop3 =& new Net_POP3();
61
 
62
 
63
 
64
//$pop3->setDebug();
65
 
66
// Connect to localhost on usual port
67
// If not given, defaults are localhost:110
68
 
69
if(PEAR::isError( $ret= $pop3->connect($host , $port ) )){
70
    echo "ERROR: " . $ret->getMessage() . "\n";
71
    exit();
72
}
73
 
74
 
75
// Login using username/password. APOP will
76
// be tried first if supported, then basic.
77
 
78
//$pop3->login($user , $pass , 'APOP');
79
//$pop3->login($user , $pass , 'CRAM-MD5');
80
 
81
if(PEAR::isError( $ret= $pop3->login($user , $pass,'USER' ) )){
82
    echo "ERROR: " . $ret->getMessage() . "\n";
83
    exit();
84
}
85
 
86
/*
87
if(PEAR::isError( $ret= $pop3->login($user , $pass ) )){
88
    echo "ERROR: " . $ret->getMessage() . "\n";
89
    exit();
90
}
91
*/
92
/*
93
if(PEAR::isError( $ret= $pop3->login($user , $pass , 'CRAM-MD5') )){
94
    echo "ERROR: " . $ret->getMessage() . "\n";
95
    exit();
96
}
97
*/
98
 
99
 
100
$a=$pop3->getListing();
101
echo "\n";
102
print_r($a);
103
//exit();
104
 
105
 
106
// Get the raw headers of message 1
107
 
108
echo "<h2>getRawHeaders()</h2>\n";
109
echo "<pre>" . htmlspecialchars($pop3->getRawHeaders(1)) . "</pre>\n";
110
 
111
 
112
// Get structured headers of message 1
113
 
114
echo "<h2>getParsedHeaders()</h2> <pre>\n";
115
print_r($pop3->getParsedHeaders(1));
116
echo "</pre>\n";
117
 
118
 
119
// Get body of message 1
120
 
121
echo "<h2>getBody()</h2>\n";
122
echo "<pre>" . htmlspecialchars($pop3->getBody(1)) . "</pre>\n";
123
 
124
 
125
// Get number of messages in maildrop
126
 
127
echo "<h2>getNumMsg</h2>\n";
128
echo "<pre>" . $pop3->numMsg() . "</pre>\n";
129
 
130
 
131
// Get entire message
132
 
133
echo "<h2>getMsg()</h2>\n";
134
echo "<pre>" . htmlspecialchars($pop3->getMsg(1)) . "</pre>\n";
135
 
136
 
137
 
138
 
139
 
140
// Get listing details of the maildrop
141
 
142
echo "<h2>getListing()</h2>\n";
143
echo "<pre>\n";
144
print_r($pop3->getListing());
145
echo "</pre>\n";
146
 
147
 
148
// Get size of maildrop
149
 
150
echo "<h2>getSize()</h2>\n";
151
echo "<pre>" . $pop3->getSize() . "</pre>\n";
152
 
153
 
154
// Disconnect
155
 
156
$pop3->disconnect();
157
?>