[英]Sending a .xls as an attachment perl using Email::MIME
以下是發送電子郵件的代碼:
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字節。 它出現在我的本地目錄中,我無法理解為什么它沒有作為附件被接收。 我也試過給出絕對路徑,但這也行不通。
好像是,你在第一個Email :: MIME> create call(for attach)中忘記了body參數。 請參閱示例perldoc Email :: MIME。
您可能希望查看Mail :: SendEasy,因為它支持SMTP身份驗證和附件。
如果您堅持使用Email :: MIME - 請在文檔中注明它建議使用Email :: Stuffer 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.