Advertisement
Guest User

Untitled

a guest
Jun 20th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #!/usr/local/bin/perl
  2.  
  3. $ARGC=@ARGV;
  4. if ($ARGC !=4) {
  5. printf "Você digitou de uma forma errada. Siga as instruções.n";
  6. printf "INSTRUÇÕES - UND3F1N3Dn";
  7. printf "perl $0 <mailist> <remetente@mail.com> <assunto> <corpo.html>n";
  8. printf "Exemplo: perl $0 lista01.txt peu@msn.com Ola index.htmln";
  9. exit(1);
  10. }
  11.  
  12. $mailtype = "content-type: text/html";
  13. $sendmail = '/usr/sbin/sendmail';
  14. $sender = $ARGV[1];
  15. $subject = $ARGV[2];
  16. $efile = $ARGV[0];
  17. $emar = $ARGV[0];
  18. open(FOO, $ARGV[3]);
  19. @foo = <FOO>;
  20. $corpo = join("n", @foo);
  21. open (BANDFIT, "$emar") || die "Can't Open $emar";
  22. $cont=0;
  23.  
  24. while(<BANDFIT>) {
  25. ($ID,$options) = split(/|/,$_);
  26. chop($options);
  27. foreach ($ID) {
  28. $recipient = $ID;
  29. open (SENDMAIL, "| $sendmail -t");
  30. print SENDMAIL "$mailtypen";
  31. print SENDMAIL "Subject: $subjectn";
  32. print SENDMAIL "From: $sendern";
  33. print SENDMAIL "To: $recipientnn";
  34. print SENDMAIL "$corponn";
  35. close (SENDMAIL);
  36. $cont=$cont+1;
  37. printf "$cont Enviado para $recipient";
  38. }
  39. }
  40. close(BANDFIT);
  41.  
  42. $tar xvfz MIME-Lite-3.01.tar.gz
  43. $cd MIME-Lite-3.01
  44. $perl Makefile.PL
  45. $make
  46. $make install
  47.  
  48. #!/usr/bin/perl
  49. use MIME::Lite;
  50.  
  51. $to = 'abcd@gmail.com';
  52. $cc = 'efgh@mail.com';
  53. $from = 'webmaster@yourdomain.com';
  54. $subject = 'Test Email';
  55. $message = 'This is test email sent by Perl Script';
  56.  
  57. $msg = MIME::Lite->new(
  58. From => $from,
  59. To => $to,
  60. Cc => $cc,
  61. Subject => $subject,
  62. Type => 'multipart/mixed'
  63. );
  64.  
  65. # Add your text message.
  66. $msg->attach(Type => 'text',
  67. Data => $message
  68. );
  69.  
  70. # Specify your file as attachement.
  71. $msg->attach(Type => 'image/gif', #Mimetype do arquivo
  72. Path => '/tmp/logo.gif', #Pasta do arquivo
  73. Filename => 'logo.gif', #Nome do arquivo
  74. Disposition => 'attachment'
  75. );
  76. $msg->send;
  77. print "Email enviado com sucesson";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement