IMAP-Client
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'IMAP::Client',
'VERSION_FROM' => 'lib/IMAP/Client.pm', # finds $VERSION
'PREREQ_PM' => {'IO::Socket::SSL' => '0',
'IO::Socket::INET' => '0',
'MIME::Base64' => '0',
'URI::imap' => '0',
'URI::Escape' => '0',
},
);
IMAP-Client - Perl module for IMAP manipulation
Copyright 2005-2006, Brenden Conte <conteb at cpan dot org> All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Prerequisites
IO::Socket, IO::Socket::SSL, MIME::Base64, URI, URI::imap, URI::Escape
Build Instructions
perl Makefile.PL
make
make test
make install
See Changelog file for information on changes between versions.
See TODO file for information on future development points.
lib/IMAP/Client.pm view on Meta::CPAN
#
use strict;
use warnings;
#use diagnostics;
package IMAP::Client;
use IO::Socket::INET;
use IO::Socket::SSL;
use MIME::Base64;
use URI::imap;
use URI::Escape;
use Exporter;
$|=1;
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
lib/IMAP/Client.pm view on Meta::CPAN
# return(@resp) :
# return($self->throw_error("$command failed: @resp"));
}
##### connect
=pod
=item B<connect(%args)>
Connect to the supplied IMAP server. Inerits all the options of IO::Socket::SSL (and thusly, IO::Socket::INET), and adds the following custom options:
=over 4
=item ConnectMethod
=over 2
Sets the priority of the login methods via a space seperated priority-ordered list. Valid methods are 'SSL', 'STARTTLS', and 'PLAIN'. The default is to try loggin in via SSL, then connecting to the standard IMAP port and negotiating STARTTLS. 'PLA...
The 'STARTTLS' method uses the starttls() command to negotiate the insecure connection to a secure status - it is functionally equivlant to using the 'PLAIN' method and subsequently calling starttls() within the program.
lib/IMAP/Client.pm view on Meta::CPAN
my ($self, %args) = @_;
$self->throw_error("No arguments supplied to connect") unless (%args);
my @methods = ($args{ConnectMethod}) ? split(' ',$args{ConnectMethod}) : qw(SSL STARTTLS);
my $connected;
my $errorstr;
my $server;
foreach my $method (@methods) {
my @resp;
if ($method eq "SSL") {
$args{PeerPort} = $args{IMAPSPort} || 993;
unless ($server = new IO::Socket::SSL(%args)) {
$errorstr .= "SSL Attempt: ". IO::Socket::SSL::errstr() ."\n";
next;
}
} elsif ($method eq 'STARTTLS') {
$args{PeerPort} = $args{IMAPPort} || 143;
unless ($server = new IO::Socket::INET(%args)) {
$errorstr .= "STARTTLS Attempt: Unable to connect: $@\n";
next;
}
} elsif ($method eq 'PLAIN') {
$args{PeerPort} = $args{IMAPPort} || 143;
lib/IMAP/Client.pm view on Meta::CPAN
# not authenticated state
=pod
=item B<starttls(%args)>
Issue a STARTTLS negotiation to secure the data connection. This function will call capability() twice - once before issuing the starttls() command to verify that the atom STARTTLS is listed as a capability(), and once after the sucessful negotiatio...
STARTTLS is checked in capability() regardless of the value of capability_checking().
Any call arguments in %args are passed onto the underlying IO::Socket::SSL->start_SSL() function.
This function returns 1 on success, since there is no output to return on success. Failures are treated normally.
=cut
sub starttls ($%){
my ($self, %args) = @_;
unless ($self->check_capability('STARTTLS')) {
return($self->throw_error("STARTTLS not found in CAPABILITY"));
}
my @recv = $self->_imap_command("STARTTLS",undef);
$self->dprint(0x01, "<TLS negotiations>\n"); # compensation for lack of tapping into dump
$args{SSL_version} ||= 'TLSv1';
if (IO::Socket::SSL->start_SSL($self->{'server'}, %args)) {
# per RFC 3501 - 6.2.1, we must re-establish the CAPABILITY of the server after STARTTLS
$self->{capability} = '';
@recv = $self->capability();
} else {
return($self->throw_error("STARTTLS Attempt: ".IO::Socket::SSL::errstr()))
}
return(@recv);
}
=pod
=item B<authenticate($login, $password)>
=item B<authenticate($login, $password, $authorize_as)>
lib/IMAP/Client.pm view on Meta::CPAN
In the last example, we assumed that we already knew the struture of the email. In real life, this is almost never the case. If you need to know what the structure of a message looks like so you can extract a small piece of it, you can use the BODY...
=head1 AUTHOR/COPYRIGHT
Copyright 2005-2006, Brenden Conte <conteb at cpan dot org> All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=head1 SEE ALSO
perl, IO::Socket, IO::Socket::SSL, MIME::Base64, URI, URI::imap, URI::Escape
=cut
1;
__END__
( run in 0.240 second using v1.01-cache-2.11-cpan-2b0bae70ee8 )