Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Mail;
- #use lib '/home/guido/workspace/Pinguer';
- use warnings;
- use strict;
- sub new($$$$$$$$);
- # Los paso como argumento al constructor..
- #my $user = 'XXXX';
- #my $pass = 'XXXX';
- #my $server = 'XXXX';
- #my $to = 'XXXX';
- #my $from_name = 'Alerta';
- #my $from_email = 'alerta@innova-red.net';
- #my $subject = "Enlace $lugar caido";
- #my $message = 'Guido que buen programador que sos';
- #$a=new($user,$pass,$server,$from_email,$to,$from_name,$subject,$message);
- #print $a;
- sub new ($$$$$$$$){
- my ($user,$pass,$server,$from_email,$to,$from_name,$subject,$message) = @_;
- my $smtps = Net::SMTP::SSL->new($server,
- Port => 465,
- Debug => 1,
- ) or warn "$!\n";
- # I just lucked out and this worked for auth (yeah inheritance :-) )
- defined ($smtps->auth($user, $pass)) or die "Can't authenticate: $!\n";
- $smtps->mail($from_email);
- $smtps->to($to);
- $smtps->data();
- $smtps->datasend("To: $to\n");
- $smtps->datasend(qq^From: "$from_name" <$from_email>\n^);
- $smtps->datasend("Subject: $subject\n\n");
- $smtps->datasend("$message\n");
- # $smtps->datasend("\n--\nVery Official Looking .sig here\n");
- $smtps->dataend();
- $smtps->quit();
- # return bless \$smtps;
- # print "done\n";
- #You can alternatively just put everything in the
- #argument to $smtps->data(),
- #and forget about datasend() and dataend();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement