在 perl 中邮寄日志文件的内容

Mail the contents of a log file in perl

我想邮寄另一个脚本的日志文件的内容。我已经尝试了它工作的代码,但是输出不是我预期的。我希望逐行输出与 LOG.txt 完全一样,但我将其作为正文中的一个段落输入。

my $HOME        ='/apps/stephen/data';
my $FILE        ="$HOME/LOG.txt";
my @HTML        =();

sub copyfile
{
 `$HOME/APPL.ksh > $FILE`;

  push(@HTML,`cat $FILE`);

&sendMail;
}

sub sendMail
{
$sub="TEST";
$from='ABC@ABC.com';
$to='ABC@ABC.com';
    open(MAIL, "|/usr/lib/sendmail -t");
            print MAIL "From: $from "; print MAIL "To: $to ";print    MAIL "Cc: $Cc ";
            print MAIL "Subject: $sub ";
            print MAIL "Content-Type: text/html ";
            print MAIL "Content-Disposition:inline ";
            print MAIL @HTML;
    close(MAIL);
}

sub init
{
    copyfile;

}
init;

添加缺失的 MIME-Version: header 以完成 Content-*: headers.

open(MAIL, "|/usr/lib/sendmail -i -t");
print MAIL << "END";
From: $from
To: $to
Cc: $Cc
Subject: $sub
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline

END
print MAIL @HTML;
close(MAIL)

;