package mail; sub send { #USAGE: #mail::send('"guillermo" ',"Prueba de correo","Cuerpo de correo electronico\n\nhttp://www.spc.org.pe") # my ($to, $from, $cc, $subject,$body) = (@_); my ($to,$subject,$body, $cc, $from) = (@_); #DEFINE EL NOMBRE DE LA PERSONA QUE ENVIARA EL CORREO ELECTRONICO # my $from = '"Inscripciones JPC2006"'; use Net::SMTP; #define el servidor SMTP que se usara para el envio de correos electronios; $smtp = Net::SMTP->new(Host => 'localhost',Hello => '127.0.0.1', Timeout => 30, Debug => 0 ); $smtp->mail($from); $smtp->to($to); # $smtp->bcc('','') if( $cc ne "" ){ my @ccArray = split( ',', $cc ); my $str = '$smtp->bcc('; my $comma = ''; foreach( @ccArray ){ $str.= "$comma '$_'"; $comma = ','; } $str .= ')'; eval( $str ); } # $smtp->bcc($ccArray); $smtp->data(); $smtp->datasend("To: ".$to."\n"); $smtp->datasend("From: ".$from."\n"); $smtp->datasend("Subject: ".$subject."\n"); $smtp->datasend("\n"); $smtp->datasend($body); $smtp->dataend(); $smtp->quit; } 1;