package mail; sub send { #USAGE: #mail::send('"guillermo" ',"Prueba de correo","Cuerpo de correo electronico\n\nhttp://www.spc.org.pe") my ($to,$subject,$body, $cc, $from) = (@_); #DEFINE EL NOMBRE DE LA PERSONA QUE ENVIARA EL CORREO ELECTRONICO # my $from = '"Inscripciones JPC2006"'; # my $from = '"Ernesto Cuadros-Vargas "'; use Net::SMTP; # $cc = '"Inscripciones" '; #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->data(); $smtp->datasend("To: ".$to."\n"); my @ccArray = split( ',', $cc ); my $str = '$smtp->bcc('; my $comma = ''; foreach( @ccArray ){ $str.= "$comma '$_'"; $comma = ','; } $str .= ')'; eval( $str ); $smtp->datasend("From: ".$from."\n"); $smtp->datasend("Subject: ".$subject."\n"); $smtp->datasend("\n"); $smtp->datasend($body); $smtp->dataend(); $smtp->quit; } 1;