Scripting >> Perl >> How to send mail using Net : : SMTP from ActivePerl distribution - v2

# sendmail('sender@somedomain.com','recipient@somedomain.com','carboncopy@somedomain.com', "Email Subject","Email Body","smtpserver.somedomain.com"); sub sendmail() { my $s_From = shift; my $s_To = shift; my $s_Cc = shift; my $s_Subj = shift; my $s_Body = shift; my $s_Svr = shift; print "To = $s_To\n"; use Net::SMTP; print "start of mail\n"; $smtp = Net::SMTP->new($s_Svr, Timeout => 60, Debug => 1); $smtp->mail($s_From); $smtp->to($s_To); $smtp->data(); $smtp->datasend("From: " . $s_From . "\n"); $smtp->datasend("To: " . $s_To . "\n"); $smtp->datasend("Cc: " . $s_Cc . "\n"); $smtp->datasend("Subject: " . $s_Subj . "\n"); $smtp->datasend( "\n"); $smtp->datasend( $s_Body . "\n"); $smtp->dataend(); $smtp->quit; print "end of mail\n"; return 1; }