Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. package Mail;
  2.  
  3. #use lib '/home/guido/workspace/Pinguer';
  4. use warnings;
  5. use strict;
  6.  
  7. sub new($$$$$$$$);
  8.  
  9. # Los paso como argumento al constructor..
  10.  
  11. #my $user = 'XXXX';
  12. #my $pass = 'XXXX';
  13. #my $server = 'XXXX';
  14. #my $to = 'XXXX';
  15. #my $from_name = 'Alerta';
  16. #my $from_email = 'alerta@innova-red.net';
  17. #my $subject = "Enlace $lugar caido";
  18. #my $message = 'Guido que buen programador que sos';
  19.  
  20. #$a=new($user,$pass,$server,$from_email,$to,$from_name,$subject,$message);
  21. #print $a;
  22.  
  23.  
  24. sub new ($$$$$$$$){
  25. my ($user,$pass,$server,$from_email,$to,$from_name,$subject,$message) = @_;
  26. my $smtps = Net::SMTP::SSL->new($server,
  27. Port => 465,
  28. Debug => 1,
  29. ) or warn "$!\n";
  30. # I just lucked out and this worked for auth (yeah inheritance :-) )
  31. defined ($smtps->auth($user, $pass)) or die "Can't authenticate: $!\n";
  32.  
  33. $smtps->mail($from_email);
  34. $smtps->to($to);
  35. $smtps->data();
  36. $smtps->datasend("To: $to\n");
  37. $smtps->datasend(qq^From: "$from_name" <$from_email>\n^);
  38. $smtps->datasend("Subject: $subject\n\n");
  39. $smtps->datasend("$message\n");
  40. # $smtps->datasend("\n--\nVery Official Looking .sig here\n");
  41. $smtps->dataend();
  42. $smtps->quit();
  43. # return bless \$smtps;
  44. # print "done\n";
  45. #You can alternatively just put everything in the
  46. #argument to $smtps->data(),
  47. #and forget about datasend() and dataend();
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement