首页 > 代码库 > perl模块发邮件
perl模块发邮件
vim sendmail.pl
#!/usr/bin/perl -w
use MIME::Lite;
sub perl_sendmail {
my $mail_to="$_[0]"; 收件人邮箱
my $from = "$_[1]"; 发件人邮箱
my $subject = "$_[2]"; 邮件标题
my $data = "http://www.mamicode.com/$_[3]"; 邮件内容
$sendmail = MIME::Lite->new(
From => $from,
To => $mail_to,
Subject => $subject,
Data => $data
);
$sendmail->attr("content-type" => "text/html");
$sendmail->send;
}
perl_sendmail(@ARGV);
给上边perl脚本执行权限就可以通过shell脚本调用上边的perl脚本了
./sendmail.pl "收件人邮箱地址" "发件人邮箱地址" "邮件标题" "邮件内容"
本文出自 “秋风颂” 博客,请务必保留此出处http://qiufengsong.blog.51cto.com/7520243/1405359