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
请将此添加到您的问题。评论中很大程度上无法阅读。 –