在标题中找不到收件人地址 - Sendmail

时间:2018-01-03 14:14:57

标签: perl sendmail

我正在使用以下代码。

我已经打印了$to变量,这很好。我仍然收到错误

  

在标题

中找不到收件人地址
my $sendmail = "/usr/sbin/sendmail -t";
my $reply_to = "Reply-to: swa.udda\@lkl.com";;
my $subject  = $lSubjectLine;
my $content  = $lMessage;
my $to       = "To: ".$lEmailAdd;
my $file     = $l_finalFile;
my $from     = "From: test.a\@lkl.com";

open( SENDMAIL, "|$sendmail" ) or die "Cannot open $sendmail: $!";
print SENDMAIL <<EOM;
$reply_to
$subject
$from
$to
$content
EOM
close(SENDMAIL);

2 个答案:

答案 0 :(得分:0)

您提供的脚本(如您提供的那样)在select * from student where (name in(1, 2, …, 1000) or name in(1001, 1002, …, 2000) or …) and (id in (1, 2, …, 1000) or id in (1001, 1002, …, 2000) or …) 标题后生成空行(标题结尾标记)。

修改脚本以检查传递给sendmail的邮件。

Reply-To:

答案 1 :(得分:0)

我知道这是一个古老的提交,但是以防万一仍然有兴趣,而不是盲目地将您的字符串放在一起,只需添加实际设置的位即可。

my $sendmail = "/usr/sbin/sendmail -t";
my $reply_to = "Reply-to: swa.udda\@lkl.com";;
my $subject  = $lSubjectLine;
my $content  = $lMessage;
my $to       = "To: ".$lEmailAdd;
my $file     = $l_finalFile;
my $from     = "From: test.a\@lkl.com";

open( SENDMAIL, "|$sendmail" ) or die "Cannot open $sendmail: $!";
print SENDMAIL join "\n", $reply_to, $from, $to, ($subject || ()), '',
                          $content;

close(SENDMAIL);