Dod*_*10x 6 perl zip smtp email-attachments
我正在尝试运行一个带有文本文件的脚本,使用Archive :: Zip压缩它,并使用Email :: Sender通过smtp将zip文件作为附件发送以创建mime消息.
我可以在perl中发送txt文件而不会损坏.我可以手动发送perl拉链文件而不会损坏.我无法通过perl发送手动压缩文件.
我怀疑我的问题是读取压缩文件或创建MIME消息.这是相关代码,它本质上是Email :: MIME概要中的代码,其中$ fileToSend是压缩文件的路径.
有任何想法吗?
use strict;
use warnings;
use Email::MIME;
use Email::Sender::Transport::SMTP;
use Email::Sender::Simple qw(sendmail);
use Archive::Zip qw( :ERROR_CODES :CONSTANTS);
use IO::All;
my $message =
Email::MIME->create(
header_str => [
From => $sender,
To => $recipient,
Subject => $subject,
],
attributes => {
filename => $filename,
content_type => 'application/zip',
disposition => 'attachment',
name => $filename,
},
body => io($fileToSend)->binary->all,
#body => io($fileToSend)->all,
);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1464 次 |
最近记录: |