Mail::POP3Client - Perl 5 module to talk to a POP3 server |
Mail::POP3Client - Perl 5 module to talk to a POP3 (RFC1939) server
use Mail::POP3Client; $pop = new Mail::POP3Client( USER => "me", PASSWORD => "mypassword", HOST => "pop3.do.main" ); for( $i = 1; $i <= $pop->Count(); $i++ ) { foreach( $pop->Head( $i ) ) { /^(From|Subject):\s+/i && print $_, "\n"; } } $pop->Close(); # OR $pop2 = new Mail::POP3Client( HOST => "pop3.otherdo.main" ); $pop2->User( "somebody" ); $pop2->Pass( "doublesecret" ); $pop2->Connect() || die $pop2->Message(); $pop2->Close();
This module implements an Object-Oriented interface to a POP3 server. It implements RFC1939 (http://www.faqs.org/rfcs/rfc1939.html)
Here is a simple example to list out the From: and Subject: headers in your remote mailbox:
#!/usr/local/bin/perl
use Mail::POP3Client;
$pop = new Mail::POP3Client( USER => "me", PASSWORD => "mypassword", HOST => "pop3.do.main" ); for ($i = 1; $i <= $pop->Count(); $i++) { foreach ( $pop->Head( $i ) ) { /^(From|Subject):\s+/i and print $_, "\n"; } print "\n"; }
Old style (deprecated): new Mail::POP3Client( USER, PASSWORD [, HOST, PORT, DEBUG, AUTH_MODE] );
New style (shown with defaults): new Mail::POP3Client( USER => ``'', PASSWORD => ``'', HOST => ``pop3'', PORT => 110, AUTH_MODE => 'PASS', DEBUG => 0, TIMEOUT => 60, );
These commands are intended to make writing a POP3 client easier. They do not necessarily map directly to POP3 commands defined in RFC1081 or RFC1939, although all commands should be supported. Some commands return multiple lines as an array in an array context.
You should give it at least 2 arguments: USER and PASSWORD. The default HOST is 'pop3' which may or may not work for you. You can specify a different PORT (be careful here).
new will attempt to Connect to and Login to the POP3 server if you supply a USER and PASSWORD. If you do not supply them in the constructor, you will need to call Connect yourself.
The valid values for AUTH_MODE are 'PASS' and 'APOP'. APOP implies that an MD5 checksum will be used instrad of passing your password in cleartext. However, if the server does not support APOP, the cleartext method will be used. Be careful.
If you enable debugging with DEBUG => 1, messages about command will go to STDERR.
Another warning, it's impossible to differentiate between a timeout and a failure.
You can also specify a number of preview lines which will be returned with the headers. This may not be supported by all POP3 server implementations as it is marked as optional in the RFC. Submitted by Dennis Moroney <dennis@hub.iwl.net>.
prints out a preview of each message, with the full header and the first 10 lines of the message (if supported by the POP3 server).
Sean Dowd <pop3client@dowds.net>
Based loosely on News::NNTPClient by Rodger Anderson <rodger@boi.hp.com>.
perl(1).
Mail::POP3Client - Perl 5 module to talk to a POP3 server |