Haineko::SMTPD::Relay::Mandrill - Mandrill/MailChimp Web API class for sending email
Send an email to a recipient via Mandrill using Web API.
use Haineko::SMTPD::Relay::Mandrill; my $h = { 'Subject' => 'Test', 'To' => 'neko@example.org' }; my $v = { 'username' => 'api_user', 'password' => 'api_key', 'ehlo' => 'UserAgent name for Furl', 'mail' => 'kijitora@example.jp', 'rcpt' => 'neko@example.org', 'head' => $h, 'body' => 'Email message', }; my $e = Haineko::SMTPD::Relay::Mandrill->new( %$v ); my $s = $e->sendmail; print $s; # 0 = Failed to send, 1 = Successfully sent print $e->response->error; # 0 = No error, 1 = Error print $e->response->dsn; # always returns undef print $e->response->code; # HTTP response code from Mandrill API warn Data::Dumper::Dumper $e->response; $VAR1 = bless( { 'dsn' => undef, 'error' => 0, 'code' => '200', 'host' => 'mandrillapp.com', 'port' => 443, 'rcpt' => 'neko@example.org', 'message' => [ 'OK' ], 'command' => 'POST' }, 'Haineko::SMTPD::Response' );
new( %arguments )
new() is a constructor of Haineko::SMTPD::Relay::Mandrill
new()
my $e = Haineko::SMTPD::Relay::Mandrill->new( 'username' => 'username', # API User for Mandrill 'password' => 'password', # API Key for Mandrill 'timeout' => 60, # Timeout for Furl 'attr' => { 'content_type' => 'text/plain' }, 'head' => { # Email header 'Subject' => 'Test', 'To' => 'neko@example.org', }, 'body' => 'Email message', # Email body 'mail' => 'kijitora@example.jp',# Envelope sender 'rcpt' => 'cat@example.org', # Envelope recipient );
sendmail
sendmail() will send email to the specified recipient via specified host.
sendmail()
my $e = Haineko::SMTPD::Relay::Mandrill->new( %argvs ); print $e->sendmail; # 0 = Failed to send, 1 = Successfully sent print Dumper $e->response; # Dumps Haineko::SMTPD::Response object
getbounce
getbounce() retrieve bounced records using Mandrill API.
getbounce()
my $e = Haineko::SMTPD::Relay::Mandrill->new( %$argvs ); print $e->getbounce; # 0 = No bounce or failed to retrieve # 1 = One or more bounced records retrieved print Data::Dumper::Dumper $e->response; $VAR1 = bless( { 'dsn' => '5.1.1', 'error' => 1, 'code' => '550', 'message' => [ '550 5.1.1 <user@example.org>... User unknown ' ], 'command' => 'POST' }, 'Haineko::SMTPD::Response' );
https://mandrillapp.com/api/docs/
https://github.com/azumakuniyuki/Haineko
azumakuniyuki <perl.org [at] azumakuniyuki.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Haineko, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Haineko
CPAN shell
perl -MCPAN -e shell install Haineko
For more information on module installation, please visit the detailed CPAN module installation guide.