package Email::Sender::Transport::SES;
# ABSTRACT: send mail via Amazon::SES
$Email::Sender::Transport::SES::VERSION = '0.06';
use Moo;
extends 'Amazon::SES';
with 'Email::Sender::Transport';
use MIME::Base64;
use MooX::Types::MooseLike::Base qw(Str);

This transport sends mail by sending it via Amazon::SES. 

To specify the parameters look at L<Amazon::SES>

  my $sender = Email::Sender::Transport::Sendmail->new(access_key => 'test', secret_key => 'asdf');
  my $sender = Email::Sender::Transport::Sendmail->new(use_iam_role => 1);

sub send_email {
  my ($self, $email, $envelope) = @_;
  my $string = $email->as_string;
  $string =~ s/\x0D\x0A/\x0A/g unless $^O eq 'MSWin32';
  my $r = $self->call('SendRawEmail', {
      'RawMessage.Data' => MIME::Base64::encode_base64($string)
  $r->is_success or  Email::Sender::Failure->throw("couldn't send message via Amazon SES: " . $r->error_message);
  return $self->success;
no Moo;

=head1 AUTHOR

Rusty Conover


Copyright (C) 2014 Lucky Dinosaur, LLC.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.14.2 or,
at your option, any later version of Perl 5 you may have available.