我的问题基于主题enter link description here
我还使用了自己的DefaultMailHeaderMapper
实现,并设置了embedded-parts-as-bytes = true
。
但是我有一个问题-我无法获得电子邮件附件。
我收到消息,但无法获取附件,因为从日志中可以看到,附件没有边界(例如,我将.gitignore文件附加到邮件中),因此MimeMessage解析器没有没有看到附件:
A15 FETCH 291 (BODY.PEEK[HEADER])
* 291 FETCH (BODY[HEADER] {860}
Content-Type: multipart/mixed; boundary="=-Kj0VeCHE3Jjjhv1T0WeN"
MIME-Version: 1.0
Message-Id: <1533397403.64233522.exgaq3po@frv34.fwdcdn.com>
X-Mailer: mail.ukr.net 5.0
To: Pasha <xxx@ukr.net>
From: =?UTF-8?b?0J/QsNCy0LXQuw==?= <xxx@ukr.net>
Date: Sat, 04 Aug 2018 18:43:37 +0300
Received: from [10.10.80.11] (helo=frv197.fwdcdn.com) by frv34.fwdcdn.com; Sat, 04 Aug
2018 18:43:37 +0300
Received: from xxx@ukr.net by frv34.fwdcdn.com; Sat, 04 Aug 2018 18:43:37 +0300
Received: from [10.10.10.34] (helo=frv34.fwdcdn.com)
by frv197.fwdcdn.com with smtp ID 1flyiP-000B5t-US
for xxx@ukr.net; Sat, 04 Aug 2018 18:43:37 +0300
Subject: test3
Return-path: <xxx@ukr.net>
)
A15 OK FETCH completed
A16 FETCH 291 (BODY.PEEK[1.MIME])
* 291 FETCH (BODY[1.MIME] {74}
Content-Type: multipart/alternative; boundary="=-Dw7rk3OclJQtNyghQ2Sv"
)
A16 OK FETCH completed
A17 FETCH 291 (BODY.PEEK[1]<0.16384>)
* 291 FETCH (BODY[1]<0> {374}
--=-Dw7rk3OclJQtNyghQ2Sv
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
Content-Length: 2
--=-Dw7rk3OclJQtNyghQ2Sv
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: base64
PGh0bWw+PGJvZHk+PHNwYW4gY2xhc3M9InhmbV84MjI2NTc1MSI+PGRpdj48YnIvPjwvZGl2Pjwv
c3Bhbj48L2JvZHk+PC9odG1sPg0K
--=-Dw7rk3OclJQtNyghQ2Sv--
)
A17 OK FETCH completed
A18 FETCH 291 (BODY.PEEK[2.MIME])
* 291 FETCH (BODY[2.MIME] {168}
Content-Type: application/octet-stream; name=".gitignore"
Content-Transfer-Encoding: base64
Content-Id: <asor_1533397403953NSzHs>
Content-Disposition: attachment
)
A18 OK FETCH completed
A19 FETCH 291 (BODY.PEEK[2]<0.172>)
* 291 FETCH (BODY[2]<0> {172}
Ly5pZGVhLw0KLy5zZXR0aW5ncy8NCi9iaW4vDQovdGFyZ2V0Lw0KLmNsYXNzcGF0aA0KLnByb2pl
Y3QNCi5naXRpZ25vcmUNCi9zcmMvbWFpbi9yZXNvdXJjZXMvZW1haWwucHJvcGVydGllcyANCi9u
YnByb2plY3Qv
)
A19 OK FETCH completed
A20 EXAMINE Download
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded)
* 291 EXISTS
* 0 RECENT
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded)]
* OK [UIDVALIDITY 1073741835]
A20 OK [READ-ONLY] SELECT completed
A21 CLOSE
A21 OK close completed
例如,下面我不使用headerMapper显示代码:
* 291 FETCH (BODY[]<0> {1730}
Return-path: <xxx@ukr.net>
Received: from [10.10.80.11] (helo=frv197.fwdcdn.com) by frv34.fwdcdn.com; Sat, 04
Aug 2018 18:43:37 +0300
Received: from [10.10.10.34] (helo=frv34.fwdcdn.com)
by frv197.fwdcdn.com with smtp ID 1flyiP-000B5t-US
for xxx@ukr.net; Sat, 04 Aug 2018 18:43:37 +0300
Date: Sat, 04 Aug 2018 18:43:37 +0300
From: =?UTF-8?b?0J/QsNCy0LXQuw==?= <yyy@ukr.net>
Subject: test3
To: Pasha <xxx@ukr.net>
X-Mailer: mail.ukr.net 5.0
Message-Id: <1533397403.64233522.exgaq3po@frv34.fwdcdn.com>
Received: from xxx@ukr.net by frv34.fwdcdn.com;
Sat, 04 Aug 2018 18:43:37 +0300
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-Kj0VeCHE3Jjjhv1T0WeN"
--=-Kj0VeCHE3Jjjhv1T0WeN
Content-Type: multipart/alternative; boundary="=-Dw7rk3OclJQtNyghQ2Sv"
--=-Dw7rk3OclJQtNyghQ2Sv
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
Content-Length: 2
--=-Dw7rk3OclJQtNyghQ2Sv
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: base64
PGh0bWw+PGJvZHk+PHNwYW4gY2xhc3M9InhmbV84MjI2NTc1MSI+PGRpdj48YnIvPjwvZGl2Pjwv
c3Bhbj48L2JvZHk+PC9odG1sPg0K
--=-Dw7rk3OclJQtNyghQ2Sv--
--=-Kj0VeCHE3Jjjhv1T0WeN
Content-Type: application/octet-stream; name=".gitignore"
Content-Transfer-Encoding: base64
Content-Id: <asor_1533397403953NSzHs>
Content-Disposition: attachment
Ly5pZGVhLw0KLy5zZXR0aW5ncy8NCi9iaW4vDQovdGFyZ2V0Lw0KLmNsYXNzcGF0aA0KLnByb2pl
Y3QNCi5naXRpZ25vcmUNCi9zcmMvbWFpbi9yZXNvdXJjZXMvZW1haWwucHJvcGVydGllcyANCi9u
YnByb2plY3Qv
--=-Kj0VeCHE3Jjjhv1T0WeN--
这是Spring Integration的错误,还是我必须添加一些配置?我使用的是Spring Integration 4.3.17,我也在5.0.5版本上尝试过。
答案 0 :(得分:0)
有关更多信息,请参见JIRA:https://jira.spring.io/browse/INT-4299。
从版本5.2
开始,我们引入了autoCloseFolder
,您可以在MailReceiver
到false
上进行配置。这样一来,与禁用的headerMapper
一起,您将在产生的消息MimeMessage
中拥有完整的原始payload
。因此,您可以根据需要解析下游的附件。
然后,如果需要,您需要从Folder
关闭IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE
。