v-lhb-mgr01:/root/mon# cat m5.pl
use Net::SMTP;
# mail_user should be [email protected]
sub send_mail{
my $to_address = shift;
my $mail_user = '[email protected]';
my $mail_pwd = 'xxxxxxxxxxxxxx';
my $mail_server = 'smtp.163.com';
my $from = "From: $mail_user\n";
my $subject = "Subject: here comes the subject\n";
my $message = <<CONTENT;
**********************
here comes the content
**********************
CONTENT
my $smtp = Net::SMTP->new($mail_server);
$smtp->auth($mail_user, $mail_pwd) || die "Auth Error! $!";
$smtp->mail($mail_user);
$smtp->to($to_address);
$smtp->data(); # begin the data
$smtp->datasend($from); # set user
$smtp->datasend($subject); # set subject
$smtp->datasend($message); # set content
$smtp->dataend();
Perl 发送邮件
最新推荐文章于 2019-02-20 20:53:09 发布