Uuencode 在电子邮件正文中显示附件内容

Uuencode 在电子邮件正文中显示附件内容

我正在使用 uuencode 和 mailx 来附加 zip 文件。在下面的代码中,if 块完美运行,我得到了 Deletions.zip 作为电子邮件中的附件。但是,每当执行 else 块时,我都不会收到附件,而是收到电子邮件正文中的二进制代码。

代码(调用linux命令的Perl代码):

open(EF,'>', "/test/emailbody.txt") or die $!;
if ($#dzones != -1) {
        unshift @dzones, "Following files have 20% or more deletions --\n\n";
        unshift @dzones, "Start time: $localtime\n\n";
        my $localtime = scalar localtime();
        push @dzones, "End time: $localtime\n\n";
        print EF @dzones;
        `cd /test/DOUT/; zip -q9 /tmp/deletions.zip ./*.*`;
        `(cat /test/emailbody.txt;uuencode /tmp/deletions.zip Deletions.zip) | mailx -s "Device deletions" vishal\@test.com`;
} else {
        push @dzones, "No files have more than 20% deletions.\n\nPlease see attached for the deletions in different zones.\n\nThanks, Vishal\n\n";
        print EF @dzones;
        `cd /test/DOUT/; zip -q9 /tmp/deletions.zip ./*.*`;
        `(cat /test/emailbody.txt;uuencode /tmp/deletions.zip Deletions.zip) | mailx -s "Device deletions" vishal\@test.com`;
}
close(EF);

当执行 else 块时,我得到的是:

begin 644 Deletions.zip
M4$L#!!0``@`(`.U6,D4]>N/[=0$``&@&```D`!4`9&5L7VYE7T%L8F5R=&%?
… [snip] …
+`"H+``"R'```````
`
end

我究竟做错了什么?

答案1

看来引起的问题是在 while 循环期间引起的cat /test/emailbody.txt;

在文件中打印时删除“,”。下面这行代码有这个问题:

push @dzones, "No files have more than 20% deletions.\n\nPlease see attached for the deletions in different zones.\n\nThanks, Vishal\n\n";

相关内容