我的脚本的这一部分通过测试电子邮件地址将电子邮件发送给自己,我需要将电子邮件格式化为:
$ keyname $ keyexpr $ keycount $ keyavailable
$ keyname $ keyexpr $ keycount $ keyavailable
$ keyname $ keyexpr $ keycount $ keyavailable
$ keyname $ keyexpr $ keycount $ keyavailable ... etc
相反,我收到的电子邮件只有一行而不是多行。我该怎么做?
if ($debug and !$hidestdout) {
$smtp = Net::SMTP->new($mailhost, Debug => 1);
}
else {
$smtp = Net::SMTP->new($mailhost);
}
eval {
$smtp->mail($mailfrom) || die("$!\n");
if ($smtp->to(split(/,/, $mailto))) {
$smtp->data();
$smtp->datasend("Subject: License File Status Report\n");
$smtp->datasend("\n");
$smtp->datasend("\t$keyname $keyexpr $keycount $keyavailable\n");
$smtp->dataend();
} else {
print "\tERROR SENDING EMAIL, RUN WITH DEBUG FOR MORE INFO: ", $smtp->message();
print "\tCHECK MAIL KEYWORDS: mailhost=$mailhost | mailfrom=$mailfrom | mailto=$mailto\n\n";
print LOGFILE "ERROR SENDING EMAIL, RUN WITH DEBUG FOR MORE INFO: ", $smtp->message() if ($log ne "");
print LOGFILE " RUN WITH DEBUG, CHECK MAIL KEYWORDS: mailhost=$mailhost | mailfrom=$mailfrom | mailto=$mailto\n" if ($log ne "");
}
$smtp->quit;
};
if ($@) {
print "\tERROR SENDING EMAIL, RUN WITH DEBUG FOR MORE INFO\n";
print "\tCHECK MAIL KEYWORDS: mailhost=$mailhost | mailfrom=$mailfrom | mailto=$mailto\n\n";
print LOGFILE "ERROR SENDING EMAIL, RUN WITH DEBUG FOR MORE INFO\n" if ($log ne "");
print LOGFILE " CHECK MAIL KEYWORDS: mailhost=$mailhost | mailfrom=$mailfrom | mailto=$mailto\n" if ($log ne "");
}
答案 0 :(得分:0)
我能够通过连接变量抓取的数据并将其分配给另一个变量来实现这一点,然后在"电子邮件正文中调用#34;。
$mail_body .= "\t$keyname $keyexpr $keycount $keyavailable\n";
...
$smtp->datasend("\t $mail_body \n");
在所有数据现在都在电子邮件消息中之后,循环之外是我结束的地方并退出电子邮件。
感谢大家的帮助!