1POP3Client(3)         User Contributed Perl Documentation        POP3Client(3)
2
3
4

NAME

6       Mail::POP3Client - Perl 5 module to talk to a POP3 (RFC1939) server
7

SYNOPSIS

9         use Mail::POP3Client;
10         $pop = new Mail::POP3Client( USER     => "me",
11                                      PASSWORD => "mypassword",
12                                      HOST     => "pop3.do.main" );
13         for( $i = 1; $i <= $pop->Count(); $i++ ) {
14           foreach( $pop->Head( $i ) ) {
15             /^(From|Subject):\s+/i && print $_, "\n";
16           }
17         }
18         $pop->Close();
19
20         # OR with SSL
21         $pop = new Mail::POP3Client( USER     => "me",
22                                      PASSWORD => "mypassword",
23                                      HOST     => "pop3.do.main",
24                                      USESSL   => true,
25                                    );
26
27         # OR
28         $pop2 = new Mail::POP3Client( HOST  => "pop3.otherdo.main" );
29         $pop2->User( "somebody" );
30         $pop2->Pass( "doublesecret" );
31         $pop2->Connect() >= 0 || die $pop2->Message();
32         $pop2->Close();
33
34         # OR to use your own SSL socket...
35         my $socket = IO::Socket::SSL->new( PeerAddr => 'pop.securedo.main',
36                                            PeerPort => 993,
37                                            Proto    => 'tcp') || die "No socket!";
38         my $pop = Mail::POP3Client->new();
39         $pop->User('somebody');
40         $pop->Pass('doublesecret');
41         $pop->Socket($socket);
42         $pop->Connect();
43

DESCRIPTION

45       This module implements an Object-Oriented interface to a POP3 server.
46       It implements RFC1939 (http://www.faqs.org/rfcs/rfc1939.html)
47

EXAMPLES

49       Here is a simple example to list out the From: and Subject: headers in
50       your remote mailbox:
51
52         #!/usr/local/bin/perl
53
54         use Mail::POP3Client;
55
56         $pop = new Mail::POP3Client( USER     => "me",
57                                      PASSWORD => "mypassword",
58                                      HOST     => "pop3.do.main" );
59         for ($i = 1; $i <= $pop->Count(); $i++) {
60           foreach ( $pop->Head( $i ) ) {
61             /^(From|Subject):\s+/i and print $_, "\n";
62           }
63           print "\n";
64         }
65

CONSTRUCTORS

67       Old style (deprecated):
68          new Mail::POP3Client( USER, PASSWORD [, HOST, PORT, DEBUG,
69       AUTH_MODE] );
70
71       New style (shown with defaults):
72          new Mail::POP3Client( USER      => "",
73                                PASSWORD  => "",
74                                HOST      => "pop3",
75                                PORT      => 110,
76                                AUTH_MODE => 'BEST',
77                                DEBUG     => 0,
78                                TIMEOUT   => 60,
79                                LOCALADDR => 'xxx.xxx.xxx.xxx[:xx]',
80                                SOCKET => undef,
81                                USESSL => 0,
82                              );
83
84       ·   USER is the userID of the account on the POP server
85
86       ·   PASSWORD is the cleartext password for the userID
87
88       ·   HOST is the POP server name or IP address (default = 'pop3')
89
90       ·   PORT is the POP server port (default = 110)
91
92       ·   DEBUG - any non-null, non-zero value turns on debugging (default =
93           0)
94
95       ·   AUTH_MODE - pass 'APOP' to force APOP (MD5) authorization. (default
96           is 'BEST')
97
98       ·   TIMEOUT - set a timeout value for socket operations (default = 60)
99
100       ·   LOCALADDR - allow selecting a local inet address to use
101

METHODS

103       These commands are intended to make writing a POP3 client easier.  They
104       do not necessarily map directly to POP3 commands defined in RFC1081 or
105       RFC1939, although all commands should be supported.  Some commands
106       return multiple lines as an array in an array context.
107
108       new( USER => 'user', PASSWORD => 'password', HOST => 'host', PORT =>
109       110, DEBUG => 0, AUTH_MODE => 'BEST', TIMEOUT => 60,, LOCALADDR =>
110       'xxx.xxx.xxx.xxx[:xx]', SOCKET => undef, USESSL => 0 ) )
111               Construct a new POP3 connection with this.  You should use the
112               hash-style constructor.  The old positional constructor is
113               deprecated and will be removed in a future release.  It is
114               strongly recommended that you convert your code to the new
115               version.
116
117               You should give it at least 2 arguments: USER and PASSWORD.
118               The default HOST is 'pop3' which may or may not work for you.
119               You can specify a different PORT (be careful here).
120
121               new will attempt to Connect to and Login to the POP3 server if
122               you supply a USER and PASSWORD.  If you do not supply them in
123               the constructor, you will need to call Connect yourself.
124
125               The valid values for AUTH_MODE are 'BEST', 'PASS', 'APOP' and
126               'CRAM-MD5'.  BEST says to try APOP if the server appears to
127               support it and it can be used to successfully log on, next try
128               similarly with CRAM-MD5, and finally revert to PASS. APOP and
129               CRAM-MD5 imply that an MD5 checksum will be used instead of
130               sending your password in cleartext.  However, if the server
131               does not claim to support APOP or CRAM-MD5, the cleartext
132               method will be used. Be careful. There are a few servers that
133               will send a timestamp in the banner greeting, but APOP will not
134               work with them (for instance if the server does not know your
135               password in cleartext).  If you think your authentication
136               information is correct, run in DEBUG mode and look for errors
137               regarding authorization.  If so, then you may have to use
138               'PASS' for that server.  The same applies to CRAM-MD5, too.
139
140               If you enable debugging with DEBUG => 1, socket traffic will be
141               echoed to STDERR.
142
143               Another warning, it's impossible to differentiate between a
144               timeout and a failure.
145
146               If you pass a true value for USESSL, the port will be changed
147               to 995 if it is not set or is 110.  Otherwise, it will use your
148               port.  If USESSL is true, IO::Socket::SSL will be loaded.  If
149               it is not in your perl, the call to connect will fail.
150
151               new returns a valid Mail::POP3Client object in all cases.  To
152               test for a connection failure, you will need to check the
153               number of messages: -1 indicates a connection error.  This will
154               likely change sometime in the future to return undef on an
155               error, setting $! as a side effect.  This change will not
156               happen in any 2.x version.
157
158       Head( MESSAGE_NUMBER [, PREVIEW_LINES ] )
159               Get the headers of the specified message, either as an array or
160               as a string, depending on context.
161
162               You can also specify a number of preview lines which will be
163               returned with the headers.  This may not be supported by all
164               POP3 server implementations as it is marked as optional in the
165               RFC.  Submitted by Dennis Moroney <dennis@hub.iwl.net>.
166
167       Body( MESSAGE_NUMBER )
168               Get the body of the specified message, either as an array of
169               lines or as a string, depending on context.
170
171       BodyToFile( FILE_HANDLE, MESSAGE_NUMBER )
172               Get the body of the specified message and write it to the given
173               file handle.  my $fh = new IO::Handle(); $fh->fdopen( fileno(
174               STDOUT ), "w" ); $pop->BodyToFile( $fh, 1 );
175
176               Does no stripping of NL or CR.
177
178       HeadAndBody( MESSAGE_NUMBER )
179               Get the head and body of the specified message, either as an
180               array of lines or as a string, depending on context.
181
182               Example
183                   foreach ( $pop->HeadAndBody( 1 ) )
184                      print $_, "\n";
185
186                   prints out the complete text of message 1.
187
188       HeadAndBodyToFile( FILE_HANDLE, MESSAGE_NUMBER )
189               Get the head and body of the specified message and write it to
190               the given file handle.  my $fh = new IO::Handle(); $fh->fdopen(
191               fileno( STDOUT ), "w" ); $pop->HeadAndBodyToFile( $fh, 1 );
192
193               Does no stripping of NL or CR.
194
195       Retrieve( MESSAGE_NUMBER )
196               Same as HeadAndBody.
197
198       RetrieveToFile( FILE_HANDLE, MESSAGE_NUMBER )
199               Same as HeadAndBodyToFile.
200
201       Delete( MESSAGE_NUMBER )
202               Mark the specified message number as DELETED.  Becomes
203               effective upon QUIT (invoking the Close method).  Can be reset
204               with a Reset message.
205
206       Connect Start the connection to the POP3 server.  You can pass in the
207               host and port.  Returns 1 if the connection succeeds, or 0 if
208               it fails (Message will contain a reason).  The constructor
209               always returns a blessed reference to a Mail::POP3Client
210               obhect.  This may change in a version 3.x release, but never in
211               a 2.x release.
212
213       Close   Close the connection gracefully.  POP3 says this will perform
214               any pending deletes on the server.
215
216       Alive   Return true or false on whether the connection is active.
217
218       Socket  Return the file descriptor for the socket, or set if supplied.
219
220       Size    Set/Return the size of the remote mailbox.  Set by POPStat.
221
222       Count   Set/Return the number of remote messages.  Set during Login.
223
224       Message The last status message received from the server or a message
225               describing any problem encountered.
226
227       State   The internal state of the connection: DEAD, AUTHORIZATION,
228               TRANSACTION.
229
230       POPStat Return the results of a POP3 STAT command.  Sets the size of
231               the mailbox.
232
233       List([message_number])
234               Returns the size of the given message number when called with
235               an argument using the following format:
236
237                  <message_number> <size_in_bytes>
238
239               If message_number is omitted, List behaves the same as
240               ListArray, returning an indexed array of the sizes of each
241               message in the same format.
242
243               You can parse the size in bytes using split:
244                ($msgnum, $size) = split('\s+', $pop -> List( n ));
245
246       ListArray
247               Return a list of sizes of each message.  This returns an
248               indexed array, with each message number as an index (starting
249               from 1) and the value as the next entry on the line.  Beware
250               that some servers send additional info for each message for the
251               list command.  That info may be lost.
252
253       Uidl( [MESSAGE_NUMBER] )
254               Return the unique ID for the given message (or all of them).
255               Returns an indexed array with an entry for each valid message
256               number.  Indexing begins at 1 to coincide with the server's
257               indexing.
258
259       Capa    Query server capabilities, as described in RFC 2449. Returns
260               the capabilities in an array. Valid in all states.
261
262       XTND    Optional extended commands.  Transaction state only.
263
264       Last    Return the number of the last message, retrieved from the
265               server.
266
267       Reset   Tell the server to unmark any message marked for deletion.
268
269       User( [USER_NAME] )
270               Set/Return the current user name.
271
272       Pass( [PASSWORD] )
273               Set/Return the current user name.
274
275       Login   Attempt to login to the server connection.
276
277       Host( [HOSTNAME] )
278               Set/Return the current host.
279
280       Port( [PORT_NUMBER] )
281               Set/Return the current port number.
282

IMAP COMPATIBILITY

284       Basic Mail::IMAPClient method calls are also supported: close, connect,
285       login, message_string, Password, and unseen.  Also, empty stubs are
286       provided for Folder, folders, Peek, select, and Uid.
287

REQUIREMENTS

289       This module does not have mandatory requirements for modules that are
290       not part of the standard Perl distribution. However, APOP needs need
291       Digest::MD5 and CRAM-MD5 needs Digest::HMAC_MD5 and MIME::Base64.
292

AUTHOR

294       Sean Dowd <pop3client@dowds.net>
295

CREDITS

297       Based loosely on News::NNTPClient by Rodger Anderson
298       <rodger@boi.hp.com>.
299

SEE ALSO

301       perl(1)
302
303       the Digest::MD5 manpage, the Digest::HMAC_MD5 manpage, the MIME::Base64
304       manpage
305
306       RFC 1939: Post Office Protocol - Version 3
307
308       RFC 2195: IMAP/POP AUTHorize Extension for Simple Challenge/Response
309
310       RFC 2449: POP3 Extension Mechanism
311
312
313
314perl v5.12.0                      2008-02-27                     POP3Client(3)
Impressum