1
任何人都可以請求在使用Email :: Simple發送郵件時附加兩個文本文件。我能夠收到郵件,但沒有附件發送郵件時無法附加附件
我已經嘗試了很多,但無法使其工作,不知道如果我有不正確的模塊。由於MIME :: Lite的創建者的建議,我不想使用MIME :: Lite。我基本上想使用我自己的SMTP細節,並得到電子郵件::發件人作爲建議。除了附件,一切都有效。
use strict;
use warnings;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP();
use Email::Simple();
use Email::Simple::Creator();
use Email::Sender::Transport::SMTP::TLS;
use Email::MIME;
use IO::All;
my $transport = Email::Sender::Transport::SMTP::TLS->new({
host => 'smtp.office365.com',
port => 587,
sasl_username => '[email protected]',
sasl_password => '[email protected]@123',
username => '[email protected]',
password => '[email protected]@123'
});
my @parts = (
Email::MIME->create(
attributes => {
content_type => "text/plain",
filename => "/tmp/ERROR1493720941.log",
charset => "US-ASCII",
disposition =>"attachment",
},
body => io("/tmp/ERROR1493720941.log")->all,
),
Email::MIME->create(
attributes => {
content_type => "text/plain",
filename => "/tmp/FAILED1493720941.log",
charset => "US-ASCII",
disposition =>"attachment",
},
body => io("/tmp/FAILED1493720941.log")->all,
),
);
my $email = Email::Simple->create(
header => [
To => '[email protected]',
From => '[email protected]',
Subject => 'Hi!',
],
body => "Hello",
parts => [ @parts ],
);
sendmail($email, { transport => $transport });
正如評論提問者@DaveCross,這裏是$的電子郵件 - 輸出> as_string
$VAR1 = 'To: [email protected]^M
From: [email protected]^M
Subject: Hi!^M
Date: Sun, 7 May 2017 07:58:46 -0400^M
^M
Hello^M
如果您在發送郵件之前打印'$ email-> as_string',您會看到什麼? –
@DaveCross $ VAR1 ='致:[email protected]^M From:[email protected]^M 主題:Hi!^ M 日期:2017年5月7日(星期日)07:58:46 -0400^M ^ M 你好^ M '; – GrSrv
請將此添加到您的問題。評論中很大程度上無法閱讀。 –