我正在为电子邮件应用程序编写 junit,该应用程序将邮件发送到 gmail 等任何外部域。我正在使用哑元(假邮件服务器)api 来处理包括 SmtpMessage、SmtpServer 等类的应用程序。我正在编写我发送的 junit统一码体
String unicodeBody = "TestBody\u0393"
但是当我从假邮件服务器收到它时,我得到它像这样“TestBody = CE = 93”。接收邮件的 smtp 服务器的代码是
SmtpMessage email=smtpServer.getReceivedEmail().next();
我不确定我在这里缺少什么?
只是为了提供信息,我将邮件作为 MimeMessage(其内容类型是多部分/替代)发送,其中内部包含两个 mimeBodyPart,即一个用于文本正文,另一个用于 html 正文。
编辑:- 完整的电子邮件正文是:-
MIME-Version: 1.0
Message-ID: <18805827.1.1355311147338.JavaMail.SMiles@INN-L-0019>
Subject: subject
Date: Wed, 12 Dec 2012 16:49:07 +0530 (IST)
To: to@email.com
Content-Type: multipart/alternative;
Reply-To: from@email.com
From: from@email.com
------=_Part_0_13986615.1355311147225Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: quoted-printable
body=CE=93------=_Part_0_13986615.1355311147225Content-Type: text/html; charset=UTF-8Content-Transfer-Encoding: quoted-printable
body=CE=93------=_Part_0_13986615.1355311147225--
------=_Part_0_13986615.1355311147225Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: quoted-printable
body=CE=93------=_Part_0_13986615.1355311147225Content-Type: text/html; charset=UTF-8Content-Transfer-Encoding: quoted-printable
body=CE=93------=_Part_0_13986615.1355311147225--
{MIME-Version=[1.0], Message-ID=[<18805827.1.1355311147338.JavaMail.Smiles@INN-L-0019>], Subject=[subject], Date=[Wed, 12 Dec 2012 16:49:07 +0530 (IST)], To=[to@email.com], Content-Type=[multipart/alternative;], Reply-To=[from@email.com], From=[from@email.com]}