AnyEvent::SMTP::Client - Simple asyncronous SMTP Client
use AnyEvent::SMTP::Client 'sendmail'; sendmail from => 'mons@cpan.org', to => 'mons@cpan.org', # SMTP host will be detected from addres by MX record data => 'Test message '.time().' '.$$, cb => sub { if (my $ok = shift) { warn "Successfully sent"; } if (my $err = shift) { warn "Failed to send: $err"; } } ;
Asyncronously connect to SMTP server, resolve MX, if needed, then send HELO => MAIL => RCPT => DATA => QUIT and return responce
Argument names are case insensitive. So, it may be calles as
sendmail From => ..., To => ..., ...
and as
sendmail from => ..., to => ..., ...
Arguments description are below
SMTP server to use. Optional. By default will be resolved MX record
SMTP server port. Optional. By default = 25
SMTP server. The same as pair of host:port
HELO message. Optional. By default = hostname()
Message text. For message composing may be used, for ex: MIME::Lite
Use timeout during network operations
Enable connection debugging
Callback.
When $args{to} is a single argument:
OK - latest response from server If OK is undef, then something failed, see ERR ERR - error response from server
When $args{to} is an array:
OK - hash of success responces or undef. keys are addresses, values are responces ERR - hash of error responces. keys are addresses, values are responces
See examples
If passed, used as group callback operand
sendmail ... cv => $cv, cb => sub { ...; };
is the same as
$cv->begin; sendmail ... cb => sub { ...; $cv->end };
Maximum number of connections to any host. Default is 10
Per-host configuration for maximum number of connection
Please note, host is hostname passed in argument, or resolved MX record.
So, if passed host = 'localhost'>, should be used $MAXCON{localhost}, if passed host = '127.0.0.1'>, should be used $MAXCON{'127.0.0.1'}
host =
$MAXCON{localhost}
$MAXCON{'127.0.0.1'}
# set default limit to 20 $AnyEvent::SMTP::Client::MAXCON = 20; # don't limit localhost connections $AnyEvent::SMTP::Client::MAXCON{'localhost'} = 0; # big limit for one of gmail MX $AnyEvent::SMTP::Client::MAXCON{'gmail-smtp-in.l.google.com.'} = 100;
Number of currently active connections
Number of currently active connections per host
Bug reports are welcome in CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-SMTP
Mons Anderson, <mons at cpan.org>
<mons at cpan.org>
Copyright 2009 Mons Anderson, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install AnyEvent::SMTP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::SMTP
CPAN shell
perl -MCPAN -e shell install AnyEvent::SMTP
For more information on module installation, please visit the detailed CPAN module installation guide.