附件代码
$msg->attach(Type => 'document/text',
Path => "C:\\SDB_Automation\\sdb_dump.txt",
Filename => 'sdb_dump.txt',
Disposition => 'attachment'
);
$msg->send;
我在文本文件中打印数据并将其保存在本地计算机中。但是,由于订阅者类型的原因,我只想发送该文件的数据而不是该文本文件。
答案 0 :(得分:0)
Perl有许多模块可以提供帮助。尝试啜饮例如。希望这有帮助。
use Email::MIME;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP::TLS;
use Path::Class qw/file/;
use File::Type;
use MIME::Base64;
$file= file(path);
$file = scalar $file->slurp;
my $newpart = Email::MIME->create(
attributes => {
content_type => type,
encoding => base64,
disposition => $attachment->{disposition}, # maybe useful rfc2387
charset => undef,
name => 'attachment',
},
body => $file,
);
push @parts , $newpart;
my $email = Email::MIME->create(
header => [
From => " ",
To => "",
Subject => "",
'Reply-To' => "",
],
parts => [@parts],
);
Email::Sender::Simple->send($email)