使用 javamail 解析 eml 无法正确识别嵌套的邮件

The parsing of an eml with javamail doesn't recognize properly nested messages

我正在使用 Javamail 1.5.6 实现 .eml 解析器,我已经开始从 msghow.java 复制 javamail 中提供的示例。

我正在测试一个包含另一个 eml 作为附件的 eml,这是一个摘录:

MIME-Version: 1.0
Date: Tue, 30 Apr 2019 16:20:45 +0200
Message-ID: <CA+fLqEW8TUfSxih9DTp2WXa63pS7wf1eZiro_9k1XS4AShN5Zg@mail.gmail.com>
Subject: Message with an eml as attachment
From: a b <ab@gmail.com>
To: cd@pec.cd.it
Content-Type: multipart/mixed; boundary="00000000000057f76c0587c01bc9"

--00000000000057f76c0587c01bc9
Content-Type: multipart/alternative; boundary="00000000000057f7670587c01bc7"

--00000000000057f7670587c01bc7
Content-Type: text/plain; charset="UTF-8"

Hello guys,

this is a simple message from a not certified account, it contains only one
attachment, an eml message

--00000000000057f7670587c01bc7
Content-Type: text/html; charset="UTF-8"

<div dir="ltr">Hello guys,<div><br></div><div>this is a simple message from a not certified account, it contains only one attachment, an eml message</div></div>
--00000000000057f76c0587c01bc9
Content-Type: message/rfc822; name="Cena zerebao.eml"
Content-Disposition: attachment; filename="Cena zerebao.eml"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_jv3vpu760
Content-ID: <f_jv3vpu760>

WC1Ob3Rlcy1JdGVtOiBGcmksIDYgSnVsIDIwMTggMTc6NDA6MDAgKzAyMDA7DQogdHlwZT00MDA7
IG5hbWU9T3JpZ2luYWxNb2RUaW1lDQpYLU5vdGVzLUl0ZW06IE1lbW87DQogbmFtZT1Gb3JtDQpY
LU5vdGVzLUl0ZW06IFN0ZE5vdGVzTHRyMjU7DQo.... and so on

Javamail 可以识别 eml,但是当我得到它的主题、日期、正文、附件等时,它们都是空的。 msghow.java 本身看不到它们。

在 javamail 之前,我用 mime4j 实现了我的解析器,我没有这个问题,但现在我想尽可能只使用 javamail 来解析 emls

来自描述 mail.mime.allowencodedmessages 属性 的 javadocs:

The MIME spec does not allow body parts of type message/* to be encoded. The Content-Transfer-Encoding header is ignored in this case. Some versions of Microsoft Outlook will incorrectly encode message attachments. Setting this System property to "true" will cause the Content-Transfer-Encoding header to be honored for message attachments. The default value of this property is false.