NAME
Haineko::SMTPD::Relay::Mandrill - Mandrill/MailChimp Web API class for sending email
DESCRIPTION
Send an email to a recipient via Mandrill using Web API.
SYNOPSIS
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' );
CLASS METHODS
new( %arguments )
new()
is a constructor of Haineko::SMTPD::Relay::Mandrill
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
);
INSTANCE METHODS
sendmail
sendmail()
will send email to the specified recipient via specified host.
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.
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' );
SEE ALSO
https://mandrillapp.com/api/docs/
REPOSITORY
https://github.com/azumakuniyuki/Haineko
AUTHOR
azumakuniyuki <perl.org [at] azumakuniyuki.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.