perl 使用Net::SMTP 发邮件

前端之家收集整理的这篇文章主要介绍了perl 使用Net::SMTP 发邮件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

use Net::SMTP;


my $email_server = 'smtp.163.com';
my $email_receivers = 'aaa@163.com';
my $email_sender = ‘aaa@163.com';

$email_body = ’hello‘;

sub sendMail

{

       my $smtp = Net::SMTP->new($email_server);

       $smtp->mail($email_sender);

              my @receivers = split(";",$email_receivers);

              $smtp->recipient(@receivers);

       $smtp->data();

       $smtp->datasend("MIME-Version: 1.0\n");

       $smtp->datasend("Content-Type: text/html; charset=us-ascii\n");

       $smtp->datasend("To: $email_receivers\n");

       $smtp->datasend("Subject: hello\n");

       $smtp->datasend("\n\n\n");

       $smtp->datasend("$email_body\n");

       $smtp->dataend();

       $smtp->quit;

}

猜你在找的Perl相关文章