| 1 | package Email::Sender::Transport::SES; | ||
| 2 | # ABSTRACT: send mail via Amazon::SES | ||
| 3 | $Email::Sender::Transport::SES::VERSION = '0.06'; | ||
| 4 | use Moo; | ||
| 5 | extends 'Amazon::SES'; | ||
| 6 | with 'Email::Sender::Transport'; | ||
| 7 | |||
| 8 | use MIME::Base64; | ||
| 9 | use MooX::Types::MooseLike::Base qw(Str); | ||
| 10 | |||
| 11 | =head2 DESCRIPTION | ||
| 12 | |||
| 13 | This transport sends mail by sending it via Amazon::SES. | ||
| 14 | |||
| 15 | To specify the parameters look at L<Amazon::SES> | ||
| 16 | |||
| 17 | my $sender = Email::Sender::Transport::Sendmail->new(access_key => 'test', secret_key => 'asdf'); | ||
| 18 | #or | ||
| 19 | my $sender = Email::Sender::Transport::Sendmail->new(use_iam_role => 1); | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | sub send_email { | ||
| 24 | my ($self, $email, $envelope) = @_; | ||
| 25 | |||
| 26 | my $string = $email->as_string; | ||
| 27 | $string =~ s/\x0D\x0A/\x0A/g unless $^O eq 'MSWin32'; | ||
| 28 | |||
| 29 | my $r = $self->call('SendRawEmail', { | ||
| 30 | 'RawMessage.Data' => MIME::Base64::encode_base64($string) | ||
| 31 | }); | ||
| 32 | |||
| 33 | $r->is_success or Email::Sender::Failure->throw("couldn't send message via Amazon SES: " . $r->error_message); | ||
| 34 | |||
| 35 | return $self->success; | ||
| 36 | } | ||
| 37 | |||
| 38 | no Moo; | ||
| 39 | 1; | ||
| 40 | |||
| 41 | =head1 AUTHOR | ||
| 42 | |||
| 43 | Rusty Conover rusty@luckydinosaur.com | ||
| 44 | |||
| 45 | =head1 COPYRIGHT AND LICENSE | ||
| 46 | |||
| 47 | Copyright (C) 2014 Lucky Dinosaur, LLC. http://www.luckydinosaur.com | ||
| 48 | |||
| 49 | This library is free software; you can redistribute it and/or modify | ||
| 50 | it under the same terms as Perl itself, either Perl version 5.14.2 or, | ||
| 51 | at your option, any later version of Perl 5 you may have available. | ||
| 52 | |||
| 53 | =cut | ||
| 54 | |||
| 55 | __END__ |