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 = "$_[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 "收件人邮箱地址" "发件人邮箱地址" "邮件标题" "邮件内容"
时间: 2024-12-14 11:27:19