Net::POP3 - Post Office Protocol 3 Client class |
Net::POP3 - Post Office Protocol 3 Client class (RFC1939)
use Net::POP3;
# Constructors $pop = Net::POP3->new('pop3host'); $pop = Net::POP3->new('pop3host', Timeout => 60); $pop = Net::POP3->new('pop3host', SSL => 1, Timeout => 60);
if ($pop->login($username, $password) > 0) { my $msgnums = $pop->list; # hashref of msgnum => size foreach my $msgnum (keys %$msgnums) { my $msg = $pop->get($msgnum); print @$msg; $pop->delete($msgnum); } }
$pop->quit;
This module implements a client interface to the POP3 protocol, enabling a perl5 application to talk to POP3 servers. This documentation assumes that you are familiar with the POP3 protocol described in RFC1939. With the IO::Socket::SSL manpage installed it also provides support for implicit and explicit TLS encryption, i.e. POP3S or POP3+STARTTLS.
A new Net::POP3 object must be created with the new method. Once this has been done, all POP3 commands are accessed via method calls on the object.
The Net::POP3 class is a subclass of Net::Cmd and (depending on avaibility) of IO::Socket::IP, IO::Socket::INET6 or IO::Socket::INET.
HOST
is the
name of the remote host to which an POP3 connection is required.
HOST
is optional. If HOST
is not given then it may instead be
passed as the Host
option described below. If neither is given then
the POP3_Hosts
specified in Net::Config
will be used.
OPTIONS
are passed in a hash like fashion, using key and value pairs.
Possible options are:
Host - POP3 host to connect to. It may be a single scalar, as defined for
the PeerAddr
option in the IO::Socket::INET manpage, or a reference to
an array with hosts to try in turn. The host method will return the value
which was used to connect to the host.
Port - port to connect to. Default - 110 for plain POP3 and 995 for POP3s (direct SSL).
SSL - If the connection should be done from start with SSL, contrary to later
upgrade with starttls
.
You can use SSL arguments as documented in the IO::Socket::SSL manpage, but it will
usually use the right arguments already.
LocalAddr and LocalPort - These parameters are passed directly to IO::Socket to allow binding the socket to a specific local address and port. For compatibility with older versions ResvPort can be used instead of LocalPort.
Domain - This parameter is passed directly to IO::Socket and makes it possible to enforce IPv4 connections even if the IO::Socket::IP manpage is used as super class. Alternatively Family can be used.
Timeout - Maximum time, in seconds, to wait for a response from the POP3 server (default: 120)
Debug - Enable debugging information
Unless otherwise stated all methods return either a true or false value, with true meaning that the operation was a success. When a method states that it returns a value, failure will be returned as undef or an empty list.
Net::POP3
inherits from Net::Cmd
so methods defined in Net::Cmd
may
be used to send commands to the remote POP3 server in addition to the methods
documented here.
PASS
is not given the
Net::POP3
uses Net::Netrc
to lookup the password using the host
and username. If the username is not specified then the current user name
will be used.
Returns the number of messages in the mailbox. However if there are no
messages on the server the string "0E0"
will be returned. This is
will give a true value in a boolean context, but zero in a numeric context.
If there was an error authenticating the user then undef will be returned.
USER
with password PASS
.
Similar to login, but the password is not sent in clear text.
To use this method you must have the Digest::MD5 or the MD5 module installed, otherwise this method will return undef.
NUMLINES
of the body for the message
MSGNUM
. Returns a reference to an array which contains the lines of text
read from the server.
list
returns the size of the message
in octets.
If called without arguments a reference to a hash is returned. The
keys will be the MSGNUM
's of all undeleted messages and the values will
be their size in octets.
MSGNUM
from the remote mailbox. If FH
is not given
then get returns a reference to an array which contains the lines of
text read from the server. If FH
is given then the lines returned
from the server are printed to the filehandle FH
.
MSGNUM
of all the messages accessed.
USER
.
MSGNUM
if given. If MSGNUM
is not
given uidl
returns a reference to a hash where the keys are the
message numbers and the values are the unique identifiers.
MSGNUM
to be deleted from the remote mailbox. All messages
that are marked to be deleted will be removed from the remote mailbox
when the server connection closed.
If a Net::POP3
object goes out of scope before quit
method is called
then the reset
method will called before the connection is closed. This
means that any messages marked to be deleted will not be.
the Net::Netrc manpage, the Net::Cmd manpage, the IO::Socket::SSL manpage
Graham Barr <gbarr@pobox.com>.
Steve Hay <shay@cpan.org> is now maintaining libnet as of version 1.22_02.
Copyright (C) 1995-2004 Graham Barr. All rights reserved.
Copyright (C) 2013-2016 Steve Hay. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e. under the terms of either the GNU General Public License or the Artistic License, as specified in the LICENCE file.
Net::POP3 - Post Office Protocol 3 Client class |