Mail-Box-POP3-3.008/0000755000175000001440000000000015111042546014370 5ustar00markovusers00000000000000Mail-Box-POP3-3.008/lib/0000755000175000001440000000000015111042546015136 5ustar00markovusers00000000000000Mail-Box-POP3-3.008/lib/Mail/0000755000175000001440000000000015111042546016020 5ustar00markovusers00000000000000Mail-Box-POP3-3.008/lib/Mail/Transport/0000755000175000001440000000000015111042546020014 5ustar00markovusers00000000000000Mail-Box-POP3-3.008/lib/Mail/Transport/POP3.pod0000644000175000001440000003200315111042544021235 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport::POP3 - receive messages via POP3 =head1 INHERITANCE Mail::Transport::POP3 is a Mail::Transport::Receive is a Mail::Transport is a Mail::Reporter =head1 SYNOPSIS my $receiver = Mail::Transport::POP3->new(...); my $message = $receiver->receive($id); =head1 DESCRIPTION Receive messages via the POP3 protocol from one remote server, as specified in rfc1939. This object hides much of the complications in the protocol and recovers broken connections automatically. Although it is part of the MailBox distribution, this object can be used separately. You probably should B module, but L. This module is the interface to POP3, whereas L hides the protocol weirdness and works as any other mail folder. Extends L<"DESCRIPTION" in Mail::Transport::Receive|Mail::Transport::Receive/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Transport::Receive|Mail::Transport::Receive/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Transport::Receive|Mail::Transport::Receive/"Constructors">. =over 4 =item $class-EB(%options) Create a new pop3 server connection. One object can only handle one connection: for a single user to one single server. If the server could not be reached, or when the login fails, this instantiating C will return C. Improves base, see L -Option --Defined in --Default authenticate 'AUTO' executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 log Mail::Reporter 'WARNINGS' password Mail::Transport undef port Mail::Transport 110 proxy Mail::Transport undef retry Mail::Transport ssl_options > timeout Mail::Transport 120 trace Mail::Reporter 'WARNINGS' use_ssl > username Mail::Transport undef via Mail::Transport 'sendmail' =over 2 =item authenticate => 'LOGIN'|'APOP'|'AUTO'|'OAUTH2'|'OAUTH2_SEP' Authenthication method. The standard defines two methods, named LOGIN and APOP. The first sends the username and password in plain text to the server to get permission, the latter encrypts this data using MD5. When AUTO is used, first APOP is tried, and then LOGIN. [3.006] OAUTH* requires the authorization token to be passed as Password. Microsoft Office365 needs C, where other oauth2 implementations use C. =item executable => $file =item hostname => $host|\@hosts =item interval => $span =item log => LEVEL =item password => $password =item port => $port =item proxy => $path =item retry => $count|undef =item ssl_options => HASH Unless overruled, C will be set to C and C to C You can also set the SSL parameters via IO::Socket::SSL subroutine set_defaults. Connections will get restarted when they are lost: you have to keep the defaults in place during POP actions. =item timeout => $span =item trace => LEVEL =item use_ssl => BOOLEAN =item username => $username =item via => CLASS|$name =back =back =head2 Attributes Extends L<"Attributes" in Mail::Transport::Receive|Mail::Transport::Receive/"Attributes">. =over 4 =item $obj-EB() Z<> =item $obj-EB() Inherited, see L =item $obj-EB() Returns C when SSL must be used. =back =head2 Receiving mail Extends L<"Receiving mail" in Mail::Transport::Receive|Mail::Transport::Receive/"Receiving mail">. =over 4 =item $obj-EB( [$unique_message_id] ) Inherited, see L =back =head2 Exchanging information =over 4 =item $obj-EB() Mark all messages that have been fetched with L for deletion. See L. =item $obj-EB(BOOLEAN, @ids) Either mark the specified message(s) to be deleted on the remote server or unmark them for deletion (if the first parameter is C). Deletion of messages will take place B when the connection is specifically disconnected or the last reference to the object goes out of scope. =item $obj-EB() Break contact with the server, if that (still) exists. Returns C if successful. Please note that even if the disconnect was not successful, all knowledge of messages etc. will be removed from the object: the object basically has reverted to the state in which it was before anything was done with the mail box. =item $obj-EB() Returns a reference to a list of ID's that have been fetched using L. This can be used to update a database of messages that were fetched (but maybe not yet deleted) from the mailbox. Please note that if the POP3 server did not support the UIDL command, this method will always return C because it is not possibly to reliably identify messages between sessions (other than looking at the contents of the messages themselves). See also L. =item $obj-EB() Returns the total number of octets used by the mailbox on the remote server. =item $obj-EB
( $id, [$bodylines] ) Returns a reference to an array which contains the header of the message with the specified C<$id>. C is returned if something has gone wrong. The optional integer C<$bodylines> specifies the number of lines from the body which should be added, by default none. » example: my $ref_lines = $pop3->header($uidl); print @$ref_lines; =item $obj-EB($id) Translates the unique C<$id> of a message into a sequence number which represents the message as long a this connection to the POP3 server exists. When the message has been deleted for some reason, C is returned. =item $obj-EB() Returns a list (in list context) or a reference to a list (in scalar context) of all IDs which are known by the server on this moment. =item $obj-EB($id) Returns a reference to an array which contains the lines of the message with the specified C<$id>. Returns C if something has gone wrong. » example: my $ref_lines = $pop3->message($uidl); print @$ref_lines; =item $obj-EB($id) Returns the size of the message which is indicated by the C<$id>, in octets. If the message has been deleted on the remote server, this will return C. =item $obj-EB() Returns (in scalar context only) the number of messages that are known to exist in the mailbox. =back =head2 Protocol internals The follow methods handle protocol internals, and should not be used by a normal user of this class. =over 4 =item $obj-EB() Establish a new connection to the POP3 server, using username and password. =item $obj-EB($socket, $data) Send C<$data> to the indicated socket and return the first line read from that socket. Logs an error if either writing to or reading from socket failed. This method does B attempt to reconnect or anything: if reading or writing the socket fails, something is very definitely wrong. =item $obj-EB($socket, $command) Sends the indicated C<$command> to the specified socket, and retrieves the response. It returns a reference to an array with all the lines that were reveived after the first C<+OK> line and before the end-of-message delimiter (a single dot on a line). Returns C whenever something has gone wrong. =item $obj-EB() Returns a connection to the POP3 server. If there was no connection yet, it will be created transparently. If the connection with the POP3 server was lost, it will be reconnected and the assures that internal state information (STAT and UIDL) is up-to-date in the object. If the contact to the server was still present, or could be established, an IO::Socket::INET object is returned. Else, C is returned and no further actions should be tried on the object. =item $obj-EB($socket) Update the current status of folder on the remote POP3 server. =back =head2 Server connection Extends L<"Server connection" in Mail::Transport::Receive|Mail::Transport::Receive/"Server connection">. =over 4 =item $obj-EB( $name, [@directories] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Represent this pop3 connection as URL. =back =head2 Error handling Extends L<"Error handling" in Mail::Transport::Receive|Mail::Transport::Receive/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $any-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $any-EB( [$level, [$strings]] ) Inherited, see L =item $any-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Transport::Receive|Mail::Transport::Receive/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Error: Cannot connect to $host:$port for POP3: $! Unsuccessful in connecting to the remote POP3 server. Cast by C =item Error: Cannot get the messages of pop3 via messages() It is not possible to retrieve all messages on a remote POP3 folder at once: each shall be taken separately. The POP3 folder will hide this for you. Cast by C =item Error: Cannot re-connect reliably to server which doesn't support UIDL. The connection to the remote POP3 was lost, and cannot be re-established because the server's protocol implementation lacks the necessary information. Cast by C =item Error: Cannot read POP3 from socket: $! It is not possible to read the success status of the previously given POP3 command. Connection lost? Cast by C =item Error: Cannot write POP3 to socket: $@ It is not possible to send a protocol command to the POP3 server. Connection lost? Cast by C =item Error: Could not authenticate using '$some' method. The authenication method to get access to the POP3 server did not result in a connection. Maybe you need a different authentication protocol, or your username with password are invalid. Cast by C =item Error: Could not authenticate using any login method. No authentication method was explicitly prescribed, so both AUTH and APOP were tried. However, both failed. There are other authentication methods, which are not defined by the main POP3 RFC rfc1939. These protocols are not implemented yet. Please contribute your implementation. Cast by C =item Error: POP3 Could not do a STAT For some weird reason, the server does not respond to the STAT call. Cast by C =item Error: POP3 requires a username and password. No username and/or no password specified for this POP3 folder, although these are obligatory parts in the protocol. Cast by C =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. Cast by C =item Error: Server at $host:$port does not seem to be talking POP3. The remote server did not respond to an initial exchange of messages as is expected by the POP3 protocol. The server has probably a different service on the specified port. Cast by C =back =head1 SEE ALSO This module is part of Mail-Box-POP3 version 3.008, built on November 24, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Box-POP3-3.008/lib/Mail/Transport/POP3.pm0000644000175000001440000002266415111042543021102 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Box-POP3 version 3.008. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport::POP3;{ our $VERSION = '3.008'; } use base 'Mail::Transport::Receive'; use strict; use warnings; use IO::Socket (); use IO::Socket::IP (); use IO::Socket::SSL qw/SSL_VERIFY_NONE/; use Socket qw/$CRLF/; use Digest::MD5 qw/md5_hex/; use MIME::Base64 qw/encode_base64/; #-------------------- sub _OK($) { substr(shift // '', 0, 3) eq '+OK' } sub init($) { my ($self, $args) = @_; $args->{via} = 'pop3'; $args->{port} ||= 110; $self->SUPER::init($args) or return; $self->{MTP_auth} = $args->{authenticate} || 'AUTO'; $self->{MTP_ssl} = $args->{use_ssl}; my $opts = $self->{MTP_ssl_opts} = $args->{ssl_options} || {}; $opts->{verify_hostname} ||= 0; $opts->{SSL_verify_mode} ||= SSL_VERIFY_NONE; $self->socket or return; # establish connection $self; } #-------------------- sub useSSL() { $_[0]->{MTP_ssl} } sub SSLOptions() { $_[0]->{MTP_ssl_opts} } #-------------------- sub ids(;@) { my $self = shift; $self->socket or return; wantarray ? @{$self->{MTP_n2uidl}} : $self->{MTP_n2uidl}; } sub messages() { my $self = shift; $self->log(ERROR =>"Cannot get the messages of pop3 via messages()."), return () if wantarray; $self->{MTP_messages}; } sub folderSize() { $_[0]->{MTP_folder_size} } sub header($;$) { my ($self, $uidl) = (shift, shift); return unless $uidl; my $bodylines = shift || 0;; my $socket = $self->socket or return; my $n = $self->id2n($uidl) or return; $self->sendList($socket, "TOP $n $bodylines$CRLF"); } sub message($;$) { my ($self, $uidl) = @_; $uidl or return; my $socket = $self->socket or return; my $n = $self->id2n($uidl) or return; my $message = $self->sendList($socket, "RETR $n$CRLF"); return unless $message; # Some POP3 servers add a trailing empty line pop @$message if @$message && $message->[-1] =~ m/^[\012\015]*$/; $self->{MTP_fetched}{$uidl} = undef # mark this ID as fetched unless exists $self->{MTP_nouidl}; $message; } sub messageSize($) { my ($self, $uidl) = @_; return unless $uidl; my $list; unless($list = $self->{MTP_n2length}) { my $socket = $self->socket or return; my $raw = $self->sendList($socket, "LIST$CRLF") or return; my @n2length; foreach (@$raw) { m#^(\d+) (\d+)#; $n2length[$1] = $2; } $self->{MTP_n2length} = $list = \@n2length; } my $n = $self->id2n($uidl) or return; $list->[$n]; } sub deleted($@) { my $dele = shift->{MTP_dele} ||= {}; (shift) ? @$dele{ @_ } = () : delete @$dele{ @_ }; } sub deleteFetched() { my $self = shift; $self->deleted(1, keys %{$self->{MTP_fetched}}); } sub disconnect() { my $self = shift; my $quit; if($self->{MTP_socket}) # can only disconnect once { if(my $socket = $self->socket) { my $dele = $self->{MTP_dele} || {}; while(my $uidl = each %$dele) { my $n = $self->id2n($uidl) or next; $self->send($socket, "DELE $n$CRLF") or last; } $quit = $self->send($socket, "QUIT$CRLF"); close $socket; } } delete @$self{ qw(MTP_socket MTP_dele MTP_uidl2n MTP_n2uidl MTP_n2length MTP_fetched) }; _OK $quit; } sub fetched(;$) { my $self = shift; return if exists $self->{MTP_nouidl}; $self->{MTP_fetched}; } sub id2n($;$) { shift->{MTP_uidl2n}{shift()} } #-------------------- sub socket() { my $self = shift; # Do we (still) have a working connection which accepts commands? my $socket = $self->_connection; return $socket if defined $socket; if(exists $self->{MTP_nouidl}) { $self->log(ERROR => "Can not re-connect reliably to server which doesn't support UIDL"); return; } # (Re-)establish the connection $socket = $self->login or return; $self->status($socket) or return; $self->{MTP_socket} = $socket; } sub send($$) { my $self = shift; my $socket = shift; my $response; if(eval {print $socket @_}) { $response = <$socket>; defined $response or $self->log(ERROR => "Cannot read POP3 from socket: $!") } else { $self->log(ERROR => "Cannot write POP3 to socket: $@"); } $response; } sub sendList($$) { my ($self, $socket) = (shift, shift); my $response = $self->send($socket, @_); $response && _OK $response or return; my @list; while(my $line = <$socket>) { last if $line =~ m#^\.\r?\n#s; $line =~ s#^\.##; push @list, $line; } \@list; } sub DESTROY() { my $self = shift; $self->SUPER::DESTROY; $self->disconnect if $self->{MTP_socket}; # only when open } sub _connection() { my $self = shift; my $socket = $self->{MTP_socket}; defined $socket or return; # Check if we (still) got a connection eval { print $socket "NOOP$CRLF" }; if($@ || ! <$socket> ) { delete $self->{MTP_socket}; return undef; } $socket; } sub login(;$) { my $self = shift; # Check if we can make a connection my ($host, $port, $username, $password) = $self->remoteHost; unless($username && $password) { $self->log(ERROR => "POP3 requires a username and password."); return; } my $socket; if($self->useSSL) { my $opts = $self->SSLOptions; $socket = eval { IO::Socket::SSL->new(PeerAddr => "$host:$port", %$opts) }; } else { $socket = eval { IO::Socket::IP->new("$host:$port") }; } unless($socket) { $self->log(ERROR => "Cannot connect to $host:$port for POP3: $!"); return; } # Check if it looks like a POP server my $connected; my $authenticate = $self->{MTP_auth}; my $welcome = <$socket>; unless(_OK $welcome) { $self->log(ERROR => "Server at $host:$port does not seem to be talking POP3."); return; } # Check APOP login if automatic or APOP specifically requested if($authenticate eq 'AUTO' || $authenticate eq 'APOP') { if($welcome =~ m#^\+OK .*(<\d+\.\d+\@[^>]+>)#) { my $md5 = md5_hex $1.$password; my $response = $self->send($socket, "APOP $username $md5$CRLF"); $connected = _OK $response; } } # Check USER/PASS login if automatic and failed or LOGIN specifically # requested. unless($connected) { if($authenticate eq 'AUTO' || $authenticate eq 'LOGIN') { my $response = $self->send($socket, "USER $username$CRLF") or return; if(_OK $response) { my $response2 = $self->send($socket, "PASS $password$CRLF") or return; $connected = _OK $response2; } } } # Try OAUTH2 login if(! $connected && $authenticate =~ /^OAUTH2/) { # Borrowed from Net::POP3::XOAuth2 0.0.2 by Kizashi Nagata (also Perl license) my $token = encode_base64 "user=$username\001auth=Bearer $password\001\001"; $token =~ s/[\r\n]//g; # no base64 newlines, anywhere if($authenticate eq 'OAUTH2_SEP') { # Microsofts way # https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth my $response = $self->send($socket, "AUTH XOAUTH2$CRLF") or return; if($response =~ /^\+/) # Office365 sends + here, not +OK { my $response2 = $self->send($socket, "$token$CRLF") or return; $connected = _OK $response2; } } else { my $response = $self->send($socket, "AUTH XOAUTH2 $token$CRLF") or return; $connected = _OK $response; } } # If we're still not connected now, we have an error unless($connected) { $self->log(ERROR => $authenticate eq 'AUTO' ? "Could not authenticate using any login method" : "Could not authenticate using '$authenticate' method"); return; } $socket; } sub status($;$) { my ($self, $socket) = @_; # Check if we can do a STAT my $stat = $self->send($socket, "STAT$CRLF") or return; if($stat !~ m#^\+OK (\d+) (\d+)#) { delete $self->{MTP_messages}; delete $self->{MTP_size}; $self->log(ERROR => "POP3 Could not do a STAT"); return; } $self->{MTP_messages} = my $nr_msgs = $1; $self->{MTP_folder_size} = $2; # Check if we can do a UIDL my $uidl = $self->send($socket, "UIDL$CRLF") or return; $self->{MTP_nouidl} = undef; delete $self->{MTP_uidl2n}; # drop the reverse lookup: UIDL -> number if(_OK $uidl) { my @n2uidl; $n2uidl[$nr_msgs] = undef; # pre-alloc while(my $line = <$socket>) { last if substr($line, 0, 1) eq '.'; $line =~ m#^(\d+) (.+?)\r?\n# or next; $n2uidl[$1] = $2; } shift @n2uidl; # make message 1 into index 0 $self->{MTP_n2uidl} = \@n2uidl; delete $self->{MTP_n2length}; delete $self->{MTP_nouidl}; } else { # We can't do UIDL, we need to fake it my $list = $self->send($socket, "LIST$CRLF") or return; my (@n2length, @n2uidl); if(_OK $list) { $n2length[$nr_msgs] = $n2uidl[$nr_msgs] = undef; # alloc all my ($host, $port) = $self->remoteHost; while(my $line = <$socket>) { last if substr($line, 0, 1) eq '.'; $line =~ m#^(\d+) (\d+)# or next; $n2length[$1] = $2; $n2uidl[$1] = "$host:$port:$1"; # fake UIDL, for id only } shift @n2length; shift @n2uidl; # make 1st message in index 0 } $self->{MTP_n2length} = \@n2length; $self->{MTP_n2uidl} = \@n2uidl; } my $i = 1; my %uidl2n = map +($_ => $i++), @{$self->{MTP_n2uidl}}; $self->{MTP_uidl2n} = \%uidl2n; 1; } #-------------------- sub url(;$) { my $self = shift; my ($host, $port, $user, $pwd) = $self->remoteHost; my $proto = $self->useSSL ? 'pop3s' : 'pop3'; "$proto://$user:$pwd\@$host:$port"; } #-------------------- 1; Mail-Box-POP3-3.008/lib/Mail/Box/0000755000175000001440000000000015111042546016550 5ustar00markovusers00000000000000Mail-Box-POP3-3.008/lib/Mail/Box/POP3s.pod0000644000175000001440000003621615111042544020166 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Box::POP3s - handle secure POP3 folders as client =head1 INHERITANCE Mail::Box::POP3s is a Mail::Box::POP3 is a Mail::Box::Net is a Mail::Box is a Mail::Reporter =head1 SYNOPSIS use Mail::Box::POP3s; my $folder = Mail::Box::POP3s->new(folder => $ENV{MAIL}, ...); =head1 DESCRIPTION This module mainly extends L. Extends L<"DESCRIPTION" in Mail::Box::POP3|Mail::Box::POP3/"DESCRIPTION">. =head1 OVERLOADED Extends L<"OVERLOADED" in Mail::Box::POP3|Mail::Box::POP3/"OVERLOADED">. =over 4 =item overload: B<""> stringification Inherited, see L =item overload: B<@{}> use as ARRAY Inherited, see L =item overload: B string comparison Inherited, see L =back =head1 METHODS Extends L<"METHODS" in Mail::Box::POP3|Mail::Box::POP3/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Box::POP3|Mail::Box::POP3/"Constructors">. =over 4 =item $class-EB(%options) Inherited, see L -Option --Defined in --Default access Mail::Box 'r' authenticate Mail::Box::POP3 'AUTO' body_delayed_type Mail::Box Mail::Message::Body::Delayed body_type Mail::Box Mail::Message::Body::Lines coerce_options Mail::Box +[] create Mail::Box extract Mail::Box 10240 field_type Mail::Box undef fix_headers Mail::Box false folder Mail::Box folderdir Mail::Box head_delayed_type Mail::Box Mail::Message::Head::Delayed head_type Mail::Box Mail::Message::Head::Complete keep_dups Mail::Box false lock_file Mail::Box undef lock_timeout Mail::Box 1 hour lock_type Mail::Box 'NONE' lock_wait Mail::Box 10 seconds locker Mail::Box undef log Mail::Reporter 'WARNINGS' manager Mail::Box undef message_type Mail::Box Mail::Box::POP3::Message multipart_type Mail::Box Mail::Message::Body::Multipart password Mail::Box::Net undef pop_client Mail::Box::POP3 undef remove_when_empty Mail::Box save_on_exit Mail::Box true server_name Mail::Box::Net undef server_port Mail::Box::Net 995 ssl_options Mail::Box::POP3 > trace Mail::Reporter 'WARNINGS' trusted Mail::Box use_ssl Mail::Box::POP3 > username Mail::Box::Net undef =over 2 =item access => $mode =item authenticate => 'LOGIN'|'APOP'|'AUTO'|'OUATH2'|'OAUTH2_SEP' =item body_delayed_type => CLASS =item body_type => CLASS|CODE =item coerce_options => ARRAY =item create => BOOLEAN =item extract => INTEGER | CODE | METHOD | 'LAZY'| 'ALWAYS' =item field_type => CLASS =item fix_headers => BOOLEAN =item folder => $name =item folderdir => $directory =item head_delayed_type => CLASS =item head_type => CLASS =item keep_dups => BOOLEAN =item lock_file => $file =item lock_timeout => $seconds =item lock_type => CLASS|STRING|ARRAY =item lock_wait => $seconds =item locker => OBJECT =item log => LEVEL =item manager => $manager =item message_type => CLASS =item multipart_type => CLASS =item password => $password =item pop_client => OBJECT =item remove_when_empty => BOOLEAN =item save_on_exit => BOOLEAN =item server_name => $host =item server_port => $number =item ssl_options => HASH =item trace => LEVEL =item trusted => BOOLEAN =item use_ssl => BOOLEAN =item username => $username =back =back =head2 Attributes Extends L<"Attributes" in Mail::Box::POP3|Mail::Box::POP3/"Attributes">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB( [$directory] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 The folder Extends L<"The folder" in Mail::Box::POP3|Mail::Box::POP3/"The folder">. =over 4 =item $obj-EB($message) Inherited, see L =item $obj-EB($messages) Inherited, see L =item $class-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB($folder, %options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Folder flags Extends L<"Folder flags" in Mail::Box::POP3|Mail::Box::POP3/"Folder flags">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [BOOLEAN] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 The messages Extends L<"The messages" in Mail::Box::POP3|Mail::Box::POP3/"The messages">. =over 4 =item $obj-EB( [$number|$message|$message_id] ) Inherited, see L =item $obj-EB($message_id) Inherited, see L =item $obj-EB( $label, [BOOLEAN, [\@msgs]] ) Inherited, see L =item $obj-EB( $index, [$message] ) Inherited, see L =item $obj-EB( $message_id, [$message] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( <'ALL'|$range|'ACTIVE'|'DELETED'|$label| !$label|$filter> ) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB($message, $message_ids, $timespan, $window) Inherited, see L =back =head2 Sub-folders Extends L<"Sub-folders" in Mail::Box::POP3|Mail::Box::POP3/"Sub-folders">. =over 4 =item $any-EB(%options) Inherited, see L =item $any-EB( $subname, [$parentname] ) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $any-EB() Inherited, see L =back =head2 Internals Extends L<"Internals" in Mail::Box::POP3|Mail::Box::POP3/"Internals">. =over 4 =item $obj-EB($message, %options) Inherited, see L =item $any-EB($folder, %options) Inherited, see L =item $obj-EB($message, $head) Inherited, see L =item $class-EB( [$foldername], %options ) Inherited, see L =item $obj-EB($message) Inherited, see L =item $obj-EB($message) Inherited, see L =item $obj-EB( [] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB($message) Inherited, see L =item $obj-EB($messages) Inherited, see L =item $obj-EB($messages) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =back =head2 Other methods Extends L<"Other methods" in Mail::Box::POP3|Mail::Box::POP3/"Other methods">. =over 4 =item $any-EB($time) Inherited, see L =back =head2 Error handling Extends L<"Error handling" in Mail::Box::POP3|Mail::Box::POP3/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $any-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $any-EB( [$level, [$strings]] ) Inherited, see L =item $any-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Box::POP3|Mail::Box::POP3/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DETAILS Extends L<"DETAILS" in Mail::Box::POP3|Mail::Box::POP3/"DETAILS">. =head1 DIAGNOSTICS =over 4 =item Error: Cannot create POP3 client for $name. The connection to the POP3 server cannot be established. You may see more, related, error messages about the failure. Cast by C =item Error: Cannot find head back for $uidl on POP3 server $name. The server told to have this message, but when asked for its headers, no single line was returned. Did the message get destroyed? Cast by C =item Error: Cannot read body for $uidl on POP3 server $name. The message's headers are retrieved from the server, but the body seems to be lost. Did the message get destroyed between reading the header and reading the body? Cast by C =item Warning: Changes not written to read-only folder $self. You have opened the folder read-only --which is the default set by L--, made modifications, and now want to close it. Set L if you want to overrule the access mode, or close the folder with L set to C. Cast by C =item Error: Copying failed for one message. For some reason, for instance disc full, removed by external process, or read-protection, it is impossible to copy one of the messages. Copying will proceed for the other messages. Cast by C =item Error: Destination folder $name is not writable. The folder where the messages are copied to is not opened with write access (see L). This has no relation with write permission to the folder which is controlled by your operating system. Cast by C =item Warning: Different messages with id $msgid The message id is discovered more than once within the same folder, but the content of the message seems to be different. This should not be possible: each message must be unique. Cast by C =item Error: Folder $name is opened read-only You can not write to this folder unless you have opened the folder to write or append with L, or the C option is set C. Cast by C =item Error: Invalid timespan '$timespan' specified. The string does not follow the strict rules of the time span syntax which is permitted as parameter. Cast by C =item Warning: Message $uidl on POP3 server $name disappeared. The server indicated the existence of this message before, however it has no information about the message anymore. Cast by C =item Warning: Message-id '$msgid' does not contain a domain. According to the RFCs, message-ids need to contain a unique random part, then an C<@>, and then a domain name. This is made to avoid the creation of two messages with the same id. The warning emerges when the C<@> is missing from the string. Cast by C =item Warning: POP3 folders cannot be deleted. Each user has only one POP3 folder on a server. This folder is created and deleted by the server's administrator only. Cast by C =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. Cast by C =item Error: Unable to create subfolder $name of $folder. The copy includes the subfolders, but for some reason it was not possible to copy one of these. Copying will proceed for all other sub-folders. Cast by C =item Error: Update of $nr messages ignored for POP3 folder $name. The standard POP3 implementation does not support writing from client back to the server. Therefore, modifications may be lost. Cast by C =item Error: Writing folder $name failed For some reason (you probably got more error messages about this problem) it is impossible to write the folder, although you should because there were changes made. Cast by C =item Error: You cannot write a message to a pop server (yet) Some extensions to the POP3 protocol do permit writing messages to the server, but the standard protocol only implements retreival. Feel invited to extend our implementation with writing. Cast by C =back =head1 SEE ALSO This module is part of Mail-Box-POP3 version 3.008, built on November 24, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Box-POP3-3.008/lib/Mail/Box/POP3/0000755000175000001440000000000015111042546017271 5ustar00markovusers00000000000000Mail-Box-POP3-3.008/lib/Mail/Box/POP3/Message.pm0000644000175000001440000000360015111042543021207 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Box-POP3 version 3.008. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Box::POP3::Message;{ our $VERSION = '3.008'; } use base 'Mail::Box::Net::Message'; use strict; use warnings; #-------------------- sub init($) { my ($self, $args) = @_; $args->{body_type} ||= 'Mail::Message::Body::Lines'; $self->SUPER::init($args); $self; } sub size($) { my $self = shift; $self->isDelayed ? $self->folder->popClient->messageSize($self->unique) : $self->SUPER::size; } sub label(@) { my $self = shift; $self->loadHead; # be sure the labels are read return $self->SUPER::label(@_) if @_==1; # POP3 can only set 'deleted' in the source folder. Don't forget my $olddel = $self->label('deleted') ? 1 : 0; my $ret = $self->SUPER::label(@_); my $newdel = $self->label('deleted') ? 1 : 0; $self->folder->popClient->deleted($newdel, $self->unique) if $newdel != $olddel; $ret; } sub labels(@) { my $self = shift; $self->loadHead; # be sure the labels are read $self->SUPER::labels(@_); } #-------------------- sub loadHead() { my $self = shift; my $head = $self->head; $head->isDelayed or return $head; $head = $self->folder->getHead($self); $self->head($head); $self->statusToLabels; # not supported by al POP3 servers $head; } sub loadBody() { my $self = shift; my $body = $self->body; $body->isDelayed or return $body; (my $head, $body) = $self->folder->getHeadAndBody($self); $self->head($head) if $head->isDelayed; $self->storeBody($body); } 1; Mail-Box-POP3-3.008/lib/Mail/Box/POP3/Test.pm0000644000175000001440000000322315111042543020543 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Box-POP3 version 3.008. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Box::POP3::Test;{ our $VERSION = '3.008'; } use base 'Exporter'; use strict; use warnings; use List::Util 'first'; use File::Spec (); use Mail::Transport::POP3 (); our @EXPORT = qw/start_pop3_server start_pop3_client/; # # Start POP3 server for tests # sub start_pop3_server($;$) { my $popbox = shift; my $setting = shift || ''; my $serverscript = File::Spec->catfile('t', 'server'); # Some complications to find-out $perl, which must be absolute and # untainted for perl5.6.1, but not for the other Perl's. my $perl = $^X; unless(File::Spec->file_name_is_absolute($perl)) { my @path = split /\:|\;/, $ENV{PATH}; $perl = first { -x $_ } map File::Spec->catfile($_, $^X), @path; } $perl =~ m/(.*)/; $perl = $1; %ENV = (); open my $server, "$perl $serverscript $popbox $setting|" or die "Could not start POP3 server\n"; my $line = <$server>; my $port = $line =~ m/(\d+)/ ? $1 : die "Did not get port specification, but '$line'"; ($server, $port); } # # START_POP3_CLIENT PORT, OPTIONS # sub start_pop3_client($@) { my ($port, @options) = @_; Mail::Transport::POP3->new( hostname => '127.0.0.1', port => $port, username => 'user', password => 'password', @options, ); } 1; Mail-Box-POP3-3.008/lib/Mail/Box/POP3/Message.pod0000644000175000001440000003710215111042544021362 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Box::POP3::Message - one message on a POP3 server =head1 INHERITANCE Mail::Box::POP3::Message is a Mail::Box::Net::Message is a Mail::Box::Message is a Mail::Message is a Mail::Reporter =head1 SYNOPSIS my $folder = new Mail::Box::POP3 ... my $message = $folder->message(10); =head1 DESCRIPTION A C represents one message on a POP3 server, maintained by a L folder. Each message is stored as separate entity on the server, and maybe temporarily in your program as well. Extends L<"DESCRIPTION" in Mail::Box::Net::Message|Mail::Box::Net::Message/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Box::Net::Message|Mail::Box::Net::Message/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Box::Net::Message|Mail::Box::Net::Message/"Constructors">. =over 4 =item $obj-EB(%options) Inherited, see L =item $class-EB(%options) Inherited, see L -Option --Defined in --Default body Mail::Message undef body_type Mail::Box::Message Mail::Message::Body::Lines deleted Mail::Message false field_type Mail::Message undef folder Mail::Box::Message head Mail::Message undef head_type Mail::Message Mail::Message::Head::Complete labels Mail::Message +{} log Mail::Reporter 'WARNINGS' messageId Mail::Message undef modified Mail::Message false size Mail::Box::Message undef trace Mail::Reporter 'WARNINGS' trusted Mail::Message false unique Mail::Box::Net::Message =over 2 =item body => $object =item body_type => CODE|$class =item deleted => BOOLEAN =item field_type => $class =item folder => $folder =item head => $object =item head_type => $class =item labels => ARRAY|HASH =item log => LEVEL =item messageId => $id =item modified => BOOLEAN =item size => $bytes =item trace => LEVEL =item trusted => BOOLEAN =item unique => STRING =back =back =head2 Attributes Extends L<"Attributes" in Mail::Box::Net::Message|Mail::Box::Net::Message/"Attributes">. =over 4 =item $obj-EB( [$folder] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$integer] ) Inherited, see L =item $obj-EB( [STRING|undef] ) Inherited, see L =back =head2 Constructing a message Extends L<"Constructing a message" in Mail::Box::Net::Message|Mail::Box::Net::Message/"Constructing a message">. =over 4 =item $obj-EB( [<$rg_object|%options>] ) Inherited, see L =item $class-EB( [$message|$part|$body], @fields, %options ) Inherited, see L =item $class-EB($body, [$head], $headers) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB(STRING) Inherited, see L =item $class-EB($fh|STRING|SCALAR|ARRAY, %options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB( [STRING|$field|$address|ARRAY-$of-$things] ) Inherited, see L =item $any-EB(STRING) Inherited, see L =back =head2 The message Extends L<"The message" in Mail::Box::Net::Message|Mail::Box::Net::Message/"The message">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($folder, %options) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB($folder, %options) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$fh] ) Inherited, see L =item $obj-EB( [$mailer], %options ) Inherited, see L =item $obj-EB() Returns the size of this message. If the message is still on the remote server, POP is used to ask for the size. When the message is already loaded onto the local system, the size of the parsed message is taken. These sizes can differ because the difference in line-ending representation. Improves base, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$fh] ) Inherited, see L =back =head2 The header Extends L<"The header" in Mail::Box::Net::Message|Mail::Box::Net::Message/"The header">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB($fieldname) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$head] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB($fieldname) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 The body Extends L<"The body" in Mail::Box::Net::Message|Mail::Box::Net::Message/"The body">. =over 4 =item $obj-EB( [$body] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB(%options) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [<'ALL'|'ACTIVE'|'DELETED'|'RECURSE'|$filter>] ) Inherited, see L =back =head2 Flags Extends L<"Flags" in Mail::Box::Net::Message|Mail::Box::Net::Message/"Flags">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB( [BOOLEAN] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB