.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "POP3Client 3pm" .TH POP3Client 3pm "2008-02-27" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mail::POP3Client \- Perl 5 module to talk to a POP3 (RFC1939) server .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 10 \& 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):\es+/i && print $_, "\en"; \& } \& } \& $pop\->Close(); \& \& # OR with SSL \& $pop = new Mail::POP3Client( USER => "me", \& PASSWORD => "mypassword", \& HOST => "pop3.do.main", \& USESSL => true, \& ); \& \& # OR \& $pop2 = new Mail::POP3Client( HOST => "pop3.otherdo.main" ); \& $pop2\->User( "somebody" ); \& $pop2\->Pass( "doublesecret" ); \& $pop2\->Connect() >= 0 || die $pop2\->Message(); \& $pop2\->Close(); \& \& # OR to use your own SSL socket... \& my $socket = IO::Socket::SSL\->new( PeerAddr => \*(Aqpop.securedo.main\*(Aq, \& PeerPort => 993, \& Proto => \*(Aqtcp\*(Aq) || die "No socket!"; \& my $pop = Mail::POP3Client\->new(); \& $pop\->User(\*(Aqsomebody\*(Aq); \& $pop\->Pass(\*(Aqdoublesecret\*(Aq); \& $pop\->Socket($socket); \& $pop\->Connect(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module implements an Object-Oriented interface to a \s-1POP3\s0 server. It implements \s-1RFC1939\s0 (http://www.faqs.org/rfcs/rfc1939.html) .SH "EXAMPLES" .IX Header "EXAMPLES" Here is a simple example to list out the From: and Subject: headers in your remote mailbox: .PP .Vb 1 \& #!/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):\es+/i and print $_, "\en"; \& } \& print "\en"; \& } .Ve .SH "CONSTRUCTORS" .IX Header "CONSTRUCTORS" Old style (deprecated): new Mail::POP3Client( \s-1USER\s0, \s-1PASSWORD\s0 [, \s-1HOST\s0, \s-1PORT\s0, \s-1DEBUG\s0, \s-1AUTH_MODE\s0] ); .PP New style (shown with defaults): new Mail::POP3Client( \s-1USER\s0 => "\*(L", \s-1PASSWORD\s0 => \*(R"\*(L", \s-1HOST\s0 => \*(R"pop3", \s-1PORT\s0 => 110, \s-1AUTH_MODE\s0 => '\s-1BEST\s0', \s-1DEBUG\s0 => 0, \s-1TIMEOUT\s0 => 60, \s-1LOCALADDR\s0 => 'xxx.xxx.xxx.xxx[:xx]', \s-1SOCKET\s0 => undef, \s-1USESSL\s0 => 0, ); .IP "\(bu" 4 \&\s-1USER\s0 is the userID of the account on the \s-1POP\s0 server .IP "\(bu" 4 \&\s-1PASSWORD\s0 is the cleartext password for the userID .IP "\(bu" 4 \&\s-1HOST\s0 is the \s-1POP\s0 server name or \s-1IP\s0 address (default = 'pop3') .IP "\(bu" 4 \&\s-1PORT\s0 is the \s-1POP\s0 server port (default = 110) .IP "\(bu" 4 \&\s-1DEBUG\s0 \- any non-null, non-zero value turns on debugging (default = 0) .IP "\(bu" 4 \&\s-1AUTH_MODE\s0 \- pass '\s-1APOP\s0' to force \s-1APOP\s0 (\s-1MD5\s0) authorization. (default is '\s-1BEST\s0') .IP "\(bu" 4 \&\s-1TIMEOUT\s0 \- set a timeout value for socket operations (default = 60) .IP "\(bu" 4 \&\s-1LOCALADDR\s0 \- allow selecting a local inet address to use .SH "METHODS" .IX Header "METHODS" These commands are intended to make writing a \s-1POP3\s0 client easier. They do not necessarily map directly to \s-1POP3\s0 commands defined in \&\s-1RFC1081\s0 or \s-1RFC1939\s0, although all commands should be supported. Some commands return multiple lines as an array in an array context. .IP "\fInew\fR( \s-1USER\s0 => 'user', \s-1PASSWORD\s0 => 'password', \s-1HOST\s0 => 'host', \s-1PORT\s0 => 110, \s-1DEBUG\s0 => 0, \s-1AUTH_MODE\s0 => '\s-1BEST\s0', \s-1TIMEOUT\s0 => 60,, \s-1LOCALADDR\s0 => 'xxx.xxx.xxx.xxx[:xx]', \s-1SOCKET\s0 => undef, \s-1USESSL\s0 => 0 ) )" 8 .IX Item "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 \s-1POP3\s0 connection with this. You should use the hash-style constructor. \fBThe 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.\fR .Sp You should give it at least 2 arguments: \s-1USER\s0 and \s-1PASSWORD\s0. The default \s-1HOST\s0 is 'pop3' which may or may not work for you. You can specify a different \s-1PORT\s0 (be careful here). .Sp new will attempt to Connect to and Login to the \s-1POP3\s0 server if you supply a \s-1USER\s0 and \s-1PASSWORD\s0. If you do not supply them in the constructor, you will need to call Connect yourself. .Sp The valid values for \s-1AUTH_MODE\s0 are '\s-1BEST\s0', '\s-1PASS\s0', '\s-1APOP\s0' and '\s-1CRAM\-MD5\s0'. \&\s-1BEST\s0 says to try \s-1APOP\s0 if the server appears to support it and it can be used to successfully log on, next try similarly with \s-1CRAM\-MD5\s0, and finally revert to \s-1PASS\s0. \s-1APOP\s0 and \s-1CRAM\-MD5\s0 imply that an \s-1MD5\s0 checksum will be used instead of sending your password in cleartext. However, \&\fBif the server does not claim to support \s-1APOP\s0 or \s-1CRAM\-MD5\s0, the cleartext method will be used. Be careful.\fR There are a few servers that will send a timestamp in the banner greeting, but \s-1APOP\s0 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 \s-1DEBUG\s0 mode and look for errors regarding authorization. If so, then you may have to use '\s-1PASS\s0' for that server. The same applies to \s-1CRAM\-MD5\s0, too. .Sp If you enable debugging with \s-1DEBUG\s0 => 1, socket traffic will be echoed to \s-1STDERR\s0. .Sp Another warning, it's impossible to differentiate between a timeout and a failure. .Sp If you pass a true value for \s-1USESSL\s0, the port will be changed to 995 if it is not set or is 110. Otherwise, it will use your port. If \s-1USESSL\s0 is true, IO::Socket::SSL will be loaded. If it is not in your perl, the call to connect will fail. .Sp 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. .IP "\fIHead\fR( \s-1MESSAGE_NUMBER\s0 [, \s-1PREVIEW_LINES\s0 ] )" 8 .IX Item "Head( MESSAGE_NUMBER [, PREVIEW_LINES ] )" Get the headers of the specified message, either as an array or as a string, depending on context. .Sp You can also specify a number of preview lines which will be returned with the headers. This may not be supported by all \s-1POP3\s0 server implementations as it is marked as optional in the \s-1RFC\s0. Submitted by Dennis Moroney . .IP "\fIBody\fR( \s-1MESSAGE_NUMBER\s0 )" 8 .IX Item "Body( MESSAGE_NUMBER )" Get the body of the specified message, either as an array of lines or as a string, depending on context. .IP "\fIBodyToFile\fR( \s-1FILE_HANDLE\s0, \s-1MESSAGE_NUMBER\s0 )" 8 .IX Item "BodyToFile( FILE_HANDLE, MESSAGE_NUMBER )" Get the body of the specified message and write it to the given file handle. my \f(CW$fh\fR = new \fIIO::Handle()\fR; \&\f(CW$fh\fR\->fdopen( fileno( \s-1STDOUT\s0 ), \*(L"w\*(R" ); \&\f(CW$pop\fR\->BodyToFile( \f(CW$fh\fR, 1 ); .Sp Does no stripping of \s-1NL\s0 or \s-1CR\s0. .IP "\fIHeadAndBody\fR( \s-1MESSAGE_NUMBER\s0 )" 8 .IX Item "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. .RS 8 .IP "Example" 4 .IX Item "Example" foreach ( \f(CW$pop\fR\->HeadAndBody( 1 ) ) print \f(CW$_\fR, \*(L"\en\*(R"; .Sp prints out the complete text of message 1. .RE .RS 8 .RE .IP "\fIHeadAndBodyToFile\fR( \s-1FILE_HANDLE\s0, \s-1MESSAGE_NUMBER\s0 )" 8 .IX Item "HeadAndBodyToFile( FILE_HANDLE, MESSAGE_NUMBER )" Get the head and body of the specified message and write it to the given file handle. my \f(CW$fh\fR = new \fIIO::Handle()\fR; \&\f(CW$fh\fR\->fdopen( fileno( \s-1STDOUT\s0 ), \*(L"w\*(R" ); \&\f(CW$pop\fR\->HeadAndBodyToFile( \f(CW$fh\fR, 1 ); .Sp Does no stripping of \s-1NL\s0 or \s-1CR\s0. .IP "\fIRetrieve\fR( \s-1MESSAGE_NUMBER\s0 )" 8 .IX Item "Retrieve( MESSAGE_NUMBER )" Same as HeadAndBody. .IP "\fIRetrieveToFile\fR( \s-1FILE_HANDLE\s0, \s-1MESSAGE_NUMBER\s0 )" 8 .IX Item "RetrieveToFile( FILE_HANDLE, MESSAGE_NUMBER )" Same as HeadAndBodyToFile. .IP "\fIDelete\fR( \s-1MESSAGE_NUMBER\s0 )" 8 .IX Item "Delete( MESSAGE_NUMBER )" Mark the specified message number as \s-1DELETED\s0. Becomes effective upon \&\s-1QUIT\s0 (invoking the Close method). Can be reset with a Reset message. .IP "\fIConnect\fR" 8 .IX Item "Connect" Start the connection to the \s-1POP3\s0 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. .IP "\fIClose\fR" 8 .IX Item "Close" Close the connection gracefully. \s-1POP3\s0 says this will perform any pending deletes on the server. .IP "\fIAlive\fR" 8 .IX Item "Alive" Return true or false on whether the connection is active. .IP "\fISocket\fR" 8 .IX Item "Socket" Return the file descriptor for the socket, or set if supplied. .IP "\fISize\fR" 8 .IX Item "Size" Set/Return the size of the remote mailbox. Set by POPStat. .IP "\fICount\fR" 8 .IX Item "Count" Set/Return the number of remote messages. Set during Login. .IP "\fIMessage\fR" 8 .IX Item "Message" The last status message received from the server or a message describing any problem encountered. .IP "\fIState\fR" 8 .IX Item "State" The internal state of the connection: \s-1DEAD\s0, \s-1AUTHORIZATION\s0, \s-1TRANSACTION\s0. .IP "\fIPOPStat\fR" 8 .IX Item "POPStat" Return the results of a \s-1POP3\s0 \s-1STAT\s0 command. Sets the size of the mailbox. .IP "\fIList\fR([message_number])" 8 .IX Item "List([message_number])" Returns the size of the given message number when called with an argument using the following format: .Sp .Vb 1 \& .Ve .Sp 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. .Sp You can parse the size in bytes using split: ($msgnum, \f(CW$size\fR) = split('\es+', \f(CW$pop\fR \-> List( n )); .IP "\fIListArray\fR" 8 .IX Item "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. .IP "\fIUidl\fR( [\s-1MESSAGE_NUMBER\s0] )" 8 .IX Item "Uidl( [MESSAGE_NUMBER] )" Return the unique \s-1ID\s0 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 server's indexing. .IP "\fICapa\fR" 8 .IX Item "Capa" Query server capabilities, as described in \s-1RFC\s0 2449. Returns the capabilities in an array. Valid in all states. .IP "\fI\s-1XTND\s0\fR" 8 .IX Item "XTND" Optional extended commands. Transaction state only. .IP "\fILast\fR" 8 .IX Item "Last" Return the number of the last message, retrieved from the server. .IP "\fIReset\fR" 8 .IX Item "Reset" Tell the server to unmark any message marked for deletion. .IP "\fIUser\fR( [\s-1USER_NAME\s0] )" 8 .IX Item "User( [USER_NAME] )" Set/Return the current user name. .IP "\fIPass\fR( [\s-1PASSWORD\s0] )" 8 .IX Item "Pass( [PASSWORD] )" Set/Return the current user name. .IP "\fILogin\fR" 8 .IX Item "Login" Attempt to login to the server connection. .IP "\fIHost\fR( [\s-1HOSTNAME\s0] )" 8 .IX Item "Host( [HOSTNAME] )" Set/Return the current host. .IP "\fIPort\fR( [\s-1PORT_NUMBER\s0] )" 8 .IX Item "Port( [PORT_NUMBER] )" Set/Return the current port number. .SH "IMAP COMPATIBILITY" .IX Header "IMAP COMPATIBILITY" 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. .SH "REQUIREMENTS" .IX Header "REQUIREMENTS" This module does not have mandatory requirements for modules that are not part of the standard Perl distribution. However, \s-1APOP\s0 needs need Digest::MD5 and \&\s-1CRAM\-MD5\s0 needs Digest::HMAC_MD5 and MIME::Base64. .SH "AUTHOR" .IX Header "AUTHOR" Sean Dowd .SH "CREDITS" .IX Header "CREDITS" Based loosely on News::NNTPClient by Rodger Anderson . .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIperl\fR\|(1) .PP the Digest::MD5 manpage, the Digest::HMAC_MD5 manpage, the MIME::Base64 manpage .PP \&\s-1RFC\s0 1939: Post Office Protocol \- Version 3 .PP \&\s-1RFC\s0 2195: \s-1IMAP/POP\s0 AUTHorize Extension for Simple Challenge/Response .PP \&\s-1RFC\s0 2449: \s-1POP3\s0 Extension Mechanism