这是发送电子邮件的代码:
use Email::MIME;
use IO::All;
my @parts = (
Email::MIME->create(
attributes => {
filename => "report.xls",
content_type => "application/vnd.ms-excel",
encoding => "base64",
},
body => "Body added as per the answer to this question" #no effect
),
Email::MIME->create(
attributes => {
content_type => "text/plain",
charset => "US-ASCII",
encoding => "base64",
},
body_str => "$body_of_message",
),
);
use Email::Send;
my $sender = Email::Send->new({mailer => 'SMTP'});
$sender->mailer_args([Host => 'localhost']);
$sender->send($email);
现在我可以发送邮件,但report.xls
它是空的,即 0 字节。它存在于我的本地目录中,我无法理解为什么它没有作为附件被拾取。我也尝试过给出绝对路径,但这也不起作用。