AnyEvent-IMAP

 view release on metacpan or  search on metacpan

LICENSE  view on Meta::CPAN


Source code for a work means the preferred form of the work for making
modifications to it.  For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.

  4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License.  However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.

  5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.

README  view on Meta::CPAN

    AnyEvent::IMAP - IMAP client library for AnyEvent

SYNOPSIS
        use AnyEvent::IMAP;

        my $imap = AnyEvent::IMAP->new(
            host   => 'server',
            user   => "USERID",
            pass   => 'password',
            port   => 993,
            ssl    => 1,
        );
        $imap->reg_cb(
            connect => sub {
                $imap->login()->cb(sub {
                    my ($ok, $line) = shift->recv;
                    ...
                }
            }
        );
        $imap->connect();

README  view on Meta::CPAN

METHODS
    And some methods are usable by Object::Event.

    my $imap = AnyEvent::IMAP->new(%args);
        Create a new instance with following attributes.

        host
        user
        pass
        port
        ssl

    my ($tag, $cv) = $imap->send_cmd($command[, $filter : CodeRef])
        Send a $command to the server. You can filter the response by
        optional $filter.

        $tag is a IMAP command tag.

        $cv is a instance of AnyEvent::CondVar. You can process the server
        response by following format.

example/demo.pl  view on Meta::CPAN

use autodie;
use AnyEvent::IMAP;
use Config::Pit;
use Log::Minimal;
use AnyEvent::IMAP::Envelope;

my $conf = pit_get('damail', require => {
    'imap_server' => 'imap server',
    imap_user => 'user',
    imap_pass => 'pass',
    imap_ssl => 1,
    imap_port => 993,
});

my $imap = AnyEvent::IMAP->new(
    host => $conf->{imap_server},
    user => $conf->{imap_user},
    pass => $conf->{imap_pass},
    ssl  => 1,
    port => 993,
);
$imap->reg_cb(
    connect => sub {
        infof("connected.");
        $imap->login()->cb(sub {
            my ($ok, $line) = shift->recv;
            if ($ok) {
                $imap->capability()->cb(sub {
                    my ($ok, $line) = shift->recv;

lib/AnyEvent/IMAP.pm  view on Meta::CPAN

use parent qw(Object::Event);

use AnyEvent::Socket;
use AnyEvent::Handle;
use AnyEvent::TLS;
use Mail::IMAP::Util;

use Mouse;

has 'socket' => (is => 'ro');
has 'ssl' => (is => 'rw', isa => 'Bool');
has 'host' => (is => 'rw');
has 'port' => (is => 'rw');
has 'user' => (is => 'rw');
has 'pass' => (is => 'rw');
has id => (is => 'ro', default => sub { 1 });

sub connect {
    my ($self) = @_;

    if ($self->{socket}) {
        $self->disconnect("reconnect requested");
    }

    my $cv = AE::cv();
    $self->{accumulator}  = [];
    $self->{lineparts}  = [];
    $self->{socket} = AnyEvent::Handle->new(
        connect => [$self->host, $self->port],
        ($self->ssl ? (tls => 'connect') : ()),
        on_connect => sub {
            my ($handle, $host, $port, $retry) = @_;
            $self->{socket}->push_read(
                line => "\r\n", sub {
                    my ($handle, $line) = @_;
                    if ($line =~ /^\*\s+OK/) {
                        $cv->send(1, $line);
                        $self->event('connect');
                    } else {
                        $cv->send(0, $line);

lib/AnyEvent/IMAP.pm  view on Meta::CPAN


=head1 SYNOPSIS

    use AnyEvent::IMAP;

    my $imap = AnyEvent::IMAP->new(
        host   => 'server',
        user   => "USERID",
        pass   => 'password',
        port   => 993,
        ssl    => 1,
    );
    $imap->reg_cb(
        connect => sub {
            $imap->login()->cb(sub {
                my ($ok, $line) = shift->recv;
                ...
            }
        }
    );
    $imap->connect();

lib/AnyEvent/IMAP.pm  view on Meta::CPAN

=over 4

=item host

=item user

=item pass

=item port

=item ssl

=back

=item my ($tag, $cv) = $imap->send_cmd($command[, $filter : CodeRef])

Send a $command to the server. You can filter the response by optional $filter.

$tag is a IMAP command tag.

$cv is a instance of L<AnyEvent::CondVar>. You can process the server response by following format.

xt/01_podspell.t  view on Meta::CPAN

Amon
Tokuhiro
Matsuno
Svn
svn
diff
Gosuke
Miyashita
mysqldiff
mmm
ssl
UTF



( run in 0.787 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )