我想发送电子邮件。我的Email::Simple
(模块版本 2.216)对象是:
Email::Simple {
body => \## EXCEPTION MESSAGE
RU Error message: Какой-то текст‚ at /home/kes/work/projects/tucha/monkeyman/lib/MaitreD.pm line 75.
,
header => Email::Simple::Header {
headers => [
To,
[
to@domain,
To: to@domain,
],
From,
[
from@domain,
From: from@domain,
],
Subject,
[
Exception,
Subject: Exception,
],
Content-Type,
[
text/plain; charset="utf8",
Content-Type: text/plain; charset="utf8",
],
Date,
Wed, 26 Feb 2020 14:30:39 +0200,
],
mycrlf =>
,
},
mycrlf =>
,
}
Net::SMTP::_SSL>>> Net::SMTP::_SSL
Net::SMTP::_SSL>>> IO::Socket::SSL(2.066)
Net::SMTP::_SSL>>> IO::Socket::IP(0.39)
Net::SMTP::_SSL>>> IO::Socket(1.38)
Net::SMTP::_SSL>>> IO::Handle(1.36)
Net::SMTP::_SSL>>> Exporter(5.72)
Net::SMTP::_SSL>>> Net::SMTP(3.08_01)
Net::SMTP::_SSL>>> Net::Cmd(3.08_01)
Net::SMTP::_SSL=GLOB(0x10293e98)>>> MAIL FROM:<from@domain>
Net::SMTP::_SSL=GLOB(0x10293e98)<<< 250 2.1.0 <from@domain> ok
Net::SMTP::_SSL=GLOB(0x10293e98)>>> RCPT TO:<to@domain>
Net::SMTP::_SSL=GLOB(0x10293e98)<<< 250 2.1.5 <to@domain> recipient ok
Net::SMTP::_SSL=GLOB(0x10293e98)>>> DATA
Net::SMTP::_SSL=GLOB(0x10293e98)<<< 354 Enter mail, end with "." on a line by itself
H1
Net::SMTP::_SSL=GLOB(0x10293e98)>>> To: to@domain
Net::SMTP::_SSL=GLOB(0x10293e98)>>> From: from@domain
Net::SMTP::_SSL=GLOB(0x10293e98)>>> Subject: Exception
Net::SMTP::_SSL=GLOB(0x10293e98)>>> Content-Type: text/plain; charset="utf8"
Net::SMTP::_SSL=GLOB(0x10293e98)>>> Date: Wed, 26 Feb 2020 14:11:55 +0200
Net::SMTP::_SSL=GLOB(0x10293e98)>>>
Net::SMTP::_SSL=GLOB(0x10293e98)>>> ## EXCEPTION MESSAGE
Net::SMTP::_SSL=GLOB(0x10293e98)>>> RU Error message: Какой-то текст at /home/kes/work/projects/tucha/monkeyman/lib/MaitreD.pm line 75.
H2
H3
Net::SMTP::_SSL=GLOB(0x10293e98)>>> .
在这里通讯停止了。我这边正在等待邮件服务器,邮件服务器正在等待我这边的东西。然后服务器因超时断开连接
/home/kes/work/projects/tucha/monkeyman/local/lib/perl5/Email/Sender/Transport/SMTP.pm
300: # -- rjbs, 2015-08-10
301: utf8::downgrade($next_hunk) if (0+Net::SMTP->VERSION || 0) < 3.07;
302:
x303: warn "H1\n";
x304: $smtp->datasend($next_hunk) or $FAULT->("error at during DATA");
x305: warn "H2\n";
306: }
307:
x308: warn "H3\n";
x309: DB::x;
>>310: $smtp->dataend or $FAULT->("error at after DATA");
x311: warn "H4\n";
如何通过正确发送 utf8 文本Email::Simple
?
我的代码:
my $email = Email::Simple->create(
header => [
To => $address,
From => $cnf->{ from },
Subject => $subject,
%$headers,
],
body => $body,
);
my $err = Email::Sender::Simple->send( $email, { transport => $transport } );
UPD
邮件正文是:
Devel::Peek::Dump( $body )
SV = IV(0xc3ff920) at 0xc3ff930
REFCNT = 2
FLAGS = (ROK)
RV = 0x10d0d530
SV = PVMG(0x10d36f60) at 0x10d0d530
REFCNT = 3
FLAGS = (OBJECT,POK,IsCOW,pPOK,UTF8)
IV = 0
NV = 0
PV = 0x10d69cd0 "## EXCEPTION MESSAGE\nRU Error message: \320\232\320\260\320\272\320\276\320\271-\321\202\320\276 \321\202\320\265\320\272\321\201\321\202 at /home/kes/work/projects/tucha/monkeyman/lib/MaitreD.pm line 75.\n\n"\0 [UTF8 "## EXCEPTION MESSAGE\nRU Error message: \x{41a}\x{430}\x{43a}\x{43e}\x{439}-\x{442}\x{43e} \x{442}\x{435}\x{43a}\x{441}\x{442} at /home/kes/work/projects/tucha/monkeyman/lib/MaitreD.pm line 75.\n\n"]
CUR = 134
LEN = 136
COW_REFCNT = 1
STASH = 0x35583d0 "Mojo::ByteStream"
当Encode::decode( 'utf8', $body )
我收到错误时:
Wide character at ...
当我Encode::encode( 'utf8', $body )
Devel::Peek::Dump( $body )
SV = PVIV(0x10c77a18) at 0xc3ff930
REFCNT = 2
FLAGS = (POK,IsCOW,pPOK)
IV = 0
PV = 0x10df0750 "## EXCEPTION MESSAGE\nRU Error message: \320\232\320\260\320\272\320\276\320\271-\321\202\320\276 \321\202\320\265\320\272\321\201\321\202 at /home/kes/work/projects/tucha/monkeyman/lib/MaitreD.pm line 75.\n\n"\0
CUR = 134
LEN = 136
COW_REFCNT = 0
并且寄出
然后一切都很好:
Net::SMTP::_SSL=GLOB(0x10e280e8)>>> .
Net::SMTP::_SSL=GLOB(0x10e280e8)<<< 250 2.0.0 Ok: queued as D83FF102BA8
H4