Software >> Development >> Languages >> Perl >> How to send mail using Net : : SMTP from ActivePerl distribution - v2 addendum

$mailbody = qq(Content-type: text/html <body> <b>test html format mail</b> </body> </html> ); #send html format mail sendmail('sender@somedomain.com','sender@somedomain.com','carboncopy@somedomain.com', "Email Subject",$mailbody,"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; }