Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use Email::MIME;
  4. use Email::Sender::Transport::SMTP;
  5. use Email::Sender::Simple qw(sendmail);
  6. use Archive::Zip qw( :ERROR_CODES :CONSTANTS);
  7. use IO::All;
  8.  
  9. my $message =
  10. Email::MIME->create(
  11. header_str => [
  12. From => $sender,
  13. To => $recipient,
  14. Subject => $subject,
  15. ],
  16. attributes => {
  17. filename => $filename,
  18. content_type => 'application/zip',
  19. disposition => 'attachment',
  20. name => $filename,
  21. },
  22. body => io($fileToSend)->binary->all,
  23. #body => io($fileToSend)->all,
  24. );
  25.  
  26. $message->encoding_set( 'base64' );
  27.  
  28. my $transport = Email::Sender::Transport::SMTP->new({
  29. host => $smtpserver,
  30. port => $smtpport,
  31. sasl_username => $smtpuser,
  32. sasl_password => $smtppassword,
  33. ssl => 'starttls'});
  34.  
  35. Email::Stuffer->from('a@a.com')
  36. ->to('b@b.com')
  37. ->text_body('hello')
  38. ->attach_file ('zipfile')
  39. ->transport($transport)
  40. ->send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement