Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # John Homer Alvero
- # May 2016
- # SESsender.pl
- #
- # Usage: cat input.csv | ./SESsender.ph
- use MIME::Entity;
- use Net::AWS::SES;
- my $ses = Net::AWS::SES->new(access_key => 'AKIA...', secret_key => '...');
- while (<>) {
- # Parse input
- my @line = split(',');
- my $username = $line[5];
- my $password = $line[6];
- my $email = $line[3];
- # Skip the header line
- next if ($username eq "User");
- # Setup the Mime object
- $msg = MIME::Entity->build(
- From => 'John Homer Alvero <john@voyager.ph>',
- To => "$email",
- Subject => 'Sample Subject',
- Data => "<html><body>Hello from SES</body></html>",
- Type => 'text/html'
- );
- $msg->attach(
- Path => File::Spec->catfile( '/path/to/file.pdf' ),
- Type => 'application/pdf',
- Encoding => 'base64'
- );
- # Send the message
- $r = $ses->send($msg);
- if ( $r->is_success ) {
- print "Mail sent to $email\n";
- } else {
- die $r->error_message;
- }
- # Wait so that we don't hit the SES sending limitation
- sleep(2);
- }
- print "Done\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement