POE-Component-Client-SMTP
view release on metacpan or search on metacpan
lib/POE/Component/Client/SMTP.pm view on Meta::CPAN
}
else {
croak q{ There's a bug in PoCoClSMTP, we really shouldn't get here!};
}
return $encoded_data;
}
sub _open_file {
my $filename = shift;
my $handle;
# does file exist and is readable?
if ( -e $filename and -r $filename ) {
$handle = gensym();
open $handle, q{<}, qq{$filename};
}
else {
$handle = undef;
}
return $handle;
}
# accessor/mutator
sub _transaction_log {
my ( $self, $log ) = ( shift, shift );
croak q{not a class method} if ( not ref $self );
if ( defined $log ) {
push @{ $self->{q{transaction_log}} }, $log;
return $self;
}
else {
return $self->{q{transaction_log}};
}
}
# END UNDER THE HOOD
1; # End of POE::Component::Client::SMTP
__END__
# POD BELOW
=head1 NAME
POE::Component::Client::SMTP - Asynchronous mail sending with POE
=head1 VERSION
Version 0.22
=head1 DESCRIPTION
PoCoClient::SMTP allows you to send email messages in an asynchronous manner,
using POE.
Thus your program isn't blocking while busy talking with an (E)SMTP server.
=head1 SYNOPSIS
B<Warning!> The following examples are B<not> complete programs, and
aren't designed to be run as full blown applications. Their purpose is to
quickly
introduce you to the module.
For complete examples, check the 'eg' directory that can be found in the
distribution's kit.
A simple example:
# load PoCoClient::SMTP
use POE::Component::Client::SMTP;
# spawn a session
POE::Component::Client::SMTP->send(
From => 'foo@baz.com',
To => 'john@doe.net',
Server => 'relay.mailer.net',
SMTP_Success => 'callback_event_for_success',
SMTP_Failure => 'callback_event_for_failure',
);
# and you are all set ;-)
A more complex example:
# load PoCoClient::SMTP
use POE::Component::Client::SMTP;
# spawn a session
POE::Component::Client::SMTP->send(
# Email related parameters
From => 'foo@baz.com',
To => [
'john@doe.net',
'andy@zzz.org',
'peter@z.net',
'george@g.com',
],
Body => \$email_body, # here's where your message is stored
Server => 'relay.mailer.net',
Timeout => 100, # 100 seconds before timeouting
# POE related parameters
Alias => 'pococlsmtpX',
SMTP_Success => 'callback_event_for_success',
SMTP_Failure => 'callback_event_for_failure',
);
# and you are all set ;-)
=head1 METHODS
Below are the methods this Component has:
=head2 send
This immediately spawns a PoCoClient::SMTP Session and registers
itself with the Kernel in order to have its job done. This method may be
overhead for sending bulk messages, as after sending one message it gets
destroyed. Maybe in the future, there will be a I<spawn> method that will keep
the Session around forever, until received a 'shutdown' like event.
( run in 1.226 second using v1.01-cache-2.11-cpan-39bf76dae61 )