|o||USER is the userID of the account on the POP server|
|o||PASSWORD is the cleartext password for the userID|
|o||HOST is the POP server name or IP address (default = pop3)|
|o||PORT is the POP server port (default = 110)|
|o||DEBUG - any non-null, non-zero value turns on debugging (default = 0)|
|o||AUTH_MODE - pass APOP to force APOP (MD5) authorization. (default is BEST)|
|o||TIMEOUT - set a timeout value for socket operations (default = 60)|
|o||LOCALADDR - allow selecting a local inet address to use|
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.
new( USER => user, PASSWORD => password, HOST => host, PORT => 110, DEBUG => 0, AUTH_MODE => BEST, TIMEOUT => 60,, LOCALADDR => xxx.xxx.xxx.xxx[:xx], SOCKET => undef, USESSL => 0 ) ) Construct a new POP3 connection with this. You should use the hash-style constructor. <B>The old positional constructor is deprecated and will be removed in a future release. It is strongly recommended that you convert your code to the new version.B>
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 BEST, PASS, APOP and CRAM-MD5. BEST says to try APOP if the server appears to support it and it can be used to successfully log on, next try similarly with CRAM-MD5, and finally revert to PASS. APOP and CRAM-MD5 imply that an MD5 checksum will be used instead of sending your password in cleartext. However, <B>if the server does not claim to support APOP or CRAM-MD5, the cleartext method will be used. Be careful.B> There are a few servers that will send a timestamp in the banner greeting, but APOP will not work with them (for instance if the server does not know your password in cleartext). If you think your authentication information is correct, run in DEBUG mode and look for errors regarding authorization. If so, then you may have to use PASS for that server. The same applies to CRAM-MD5, too.
If you enable debugging with DEBUG => 1, socket traffic will be echoed to STDERR.
Another warning, its impossible to differentiate between a timeout and a failure.
If you pass a true value for USESSL, the port will be changed to 995 if it is not set or is 110. Otherwise, it will use your port. If USESSL is true, IO::Socket::SSL will be loaded. If it is not in your perl, the call to connect will fail.
new returns a valid Mail::POP3Client object in all cases. To test for a connection failure, you will need to check the number of messages: -1 indicates a connection error. This will likely change sometime in the future to return undef on an error, setting $! as a side effect. This change will not happen in any 2.x version.
Head( MESSAGE_NUMBER [, PREVIEW_LINES ] ) Get the headers of the specified message, either as an array or as a string, depending on context.
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 <email@example.com>.
Body( MESSAGE_NUMBER ) Get the body of the specified message, either as an array of lines or as a string, depending on context. BodyToFile( FILE_HANDLE, MESSAGE_NUMBER ) Get the body of the specified message and write it to the given file handle. my $fh = new IO::Handle(); $fh->fdopen( fileno( STDOUT ), w ); $pop->BodyToFile( $fh, 1 );
Does no stripping of NL or CR.
HeadAndBody( MESSAGE_NUMBER ) Get the head and body of the specified message, either as an array of lines or as a string, depending on context.
Example foreach ( $pop->HeadAndBody( 1 ) )
print $_, \n;
prints out the complete text of message 1.
HeadAndBodyToFile( FILE_HANDLE, MESSAGE_NUMBER ) Get the head and body of the specified message and write it to the given file handle. my $fh = new IO::Handle(); $fh->fdopen( fileno( STDOUT ), w ); $pop->HeadAndBodyToFile( $fh, 1 );
Does no stripping of NL or CR.
Retrieve( MESSAGE_NUMBER ) Same as HeadAndBody. RetrieveToFile( FILE_HANDLE, MESSAGE_NUMBER ) Same as HeadAndBodyToFile. Delete( MESSAGE_NUMBER ) Mark the specified message number as DELETED. Becomes effective upon QUIT (invoking the Close method). Can be reset with a Reset message. Connect Start the connection to the POP3 server. You can pass in the host and port. Returns 1 if the connection succeeds, or 0 if it fails (Message will contain a reason). The constructor always returns a blessed reference to a Mail::POP3Client obhect. This may change in a version 3.x release, but never in a 2.x release. Close Close the connection gracefully. POP3 says this will perform any pending deletes on the server. Alive Return true or false on whether the connection is active. Socket Return the file descriptor for the socket, or set if supplied. Size Set/Return the size of the remote mailbox. Set by POPStat. Count Set/Return the number of remote messages. Set during Login. Message The last status message received from the server or a message describing any problem encountered. State The internal state of the connection: DEAD, AUTHORIZATION, TRANSACTION. POPStat Return the results of a POP3 STAT command. Sets the size of the mailbox. List([message_number]) Returns the size of the given message number when called with an argument using the following format:
If message_number is omitted, List behaves the same as ListArray, returning an indexed array of the sizes of each message in the same format.
You can parse the size in bytes using split:
($msgnum, $size) = split(\s+, $pop -> List( n ));
ListArray Return a list of sizes of each message. This returns an indexed array, with each message number as an index (starting from 1) and the value as the next entry on the line. Beware that some servers send additional info for each message for the list command. That info may be lost. Uidl( [MESSAGE_NUMBER] ) Return the unique ID for the given message (or all of them). Returns an indexed array with an entry for each valid message number. Indexing begins at 1 to coincide with the servers indexing. Capa Query server capabilities, as described in RFC 2449. Returns the capabilities in an array. Valid in all states. XTND Optional extended commands. Transaction state only. Last Return the number of the last message, retrieved from the server. Reset Tell the server to unmark any message marked for deletion. User( [USER_NAME] ) Set/Return the current user name. Pass( [PASSWORD] ) Set/Return the current user name. Login Attempt to login to the server connection. Host( [HOSTNAME] ) Set/Return the current host. Port( [PORT_NUMBER] ) Set/Return the current port number.
Basic Mail::IMAPClient method calls are also supported: close, connect, login, message_string, Password, and unseen. Also, empty stubs are provided for Folder, folders, Peek, select, and Uid.
This module does not have mandatory requirements for modules that are not part of the standard Perl distribution. However, APOP needs need Digest::MD5 and CRAM-MD5 needs Digest::HMAC_MD5 and MIME::Base64.
Sean Dowd <firstname.lastname@example.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Based loosely on News::NNTPClient by Rodger Anderson <email@example.com>.
RFC 1939: Post Office Protocol - Version 3
RFC 2195: IMAP/POP AUTHorize Extension for Simple Challenge/Response
RFC 2449: POP3 Extension Mechanism
|perl v5.20.3||MAIL::POP3CLIENT (3)||2013-10-03|