| 1 | package IO::Socket::CLI::POP3S; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | IO::Socket::CLI::POP3S - Command-line interface to an SSL POP3 server. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 VERSION | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Version 0.04 | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | use IO::Socket::CLI::POP3S; | ||||||||||||||||||||||||||||
| 14 | my $pop3 = IO::Socket::CLI::POP3S->new(HOST => 'pop.gmail.com'); | ||||||||||||||||||||||||||||
| 15 | $pop3->read(); | ||||||||||||||||||||||||||||
| 16 | do { | ||||||||||||||||||||||||||||
| 17 | $pop3->prompt(); | ||||||||||||||||||||||||||||
| 18 | $pop3->read(); | ||||||||||||||||||||||||||||
| 19 | } while ($pop3->is_open()); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | C<IO::Socket::CLI::POP3S> provides a command-line interface to | ||||||||||||||||||||||||||||
| 24 | L<IO::Socket::INET6> and L<IO::Socket::SSL>. | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =for comment | ||||||||||||||||||||||||||||
| 27 | =head1 EXPORT | ||||||||||||||||||||||||||||
| 28 | None by default. | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use IO::Socket::CLI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 1 | @ISA = ("IO::Socket::CLI"); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | $IO::Socket::CLI::PORT = '995'; | |||||||||||||||||||||||||||
| 36 | 1 | $IO::Socket::CLI::SSL = 1; | |||||||||||||||||||||||||||
| 37 | 1 | $IO::Socket::CLI::BYE = qr'^\+OK(?: |\r?$)'; # string received when a POP3 server disconnects, | |||||||||||||||||||||||||||
| 38 | # or anything else goes right. hence, is_open() is overridden. | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head1 METHODS | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | See C<IO::Socket::CLI>. | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head2 is_open() | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Returns if the server hung up according to the last server response. | ||||||||||||||||||||||||||||
| 47 | Override as POP3 gives no special response for closing a connection, so this | ||||||||||||||||||||||||||||
| 48 | verifies an C<+OK> response after sending a C<quit> command. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =cut | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub is_open { | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
is_open: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $self->{_OPEN} = ($self->{_SOCKET}->connected()) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | foreach (@{$self->{_SERVER_RESPONSE}}) { | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | $self->{_OPEN} = 0 if (/$BYE/ && $self->{_COMMAND} =~ /^quit$/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/$BYE/ and $self->{"_COMMAND"} =~ /^quit$/i
MC/DC0%0/2
/$BYE/ and $self->{"_COMMAND"} =~ /^quit$/i
/$BYE/
$self->{"_COMMAND"} =~ /^quit$/i
Truth table0%0/3
A and B
A= /$BYE/B= $self->{"_COMMAND"} =~ /^quit$/i
| |||||||||||||||||||||||||||||
| 57 | 0 | last; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 0 | return $self->{_OPEN}; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head1 BUGS | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | Does not verify SSL connections. Has not been tried with STARTTLS. | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =over 2 | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =item * CPAN Bug Tracker | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=IO-Socket-CLI> | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =item * Code, Pull Requests, alternative Issues Tracker | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | L<https://gitable.org/ashley/IO-Socket-CLI.git> | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =back | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | Copyright (C) 2012 by Ashley Willis E<lt>ashleyw@cpan.orgE<gt> | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 85 | it under the same terms as Perl itself, either Perl version 5.12.4 or, | ||||||||||||||||||||||||||||
| 86 | at your option, any later version of Perl 5 you may have available. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | L<IO::Socket::CLI>, L<IO::Socket::INET6>, L<IO::Socket::INET>, | ||||||||||||||||||||||||||||
| 91 | L<IO::Socket::SSL>, L<IO::Socket> | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 1 | 1; | |||||||||||||||||||||||||||