简体   繁体   English

Javamail标头解析错误

[英]Javamail header parsing error

I'm using the Javamail library to retrieve messages from a Postfix email server. 我正在使用Javamail库从Postfix电子邮件服务器检索消息。 I've run into a problem with some delivery failure notifications. 我遇到了一些传递失败通知的问题。 I have tracked the issue down to the header parsing routine, where an exception is thrown when trying to parse the following header: 我已将问题跟踪到标头解析例程,在尝试解析以下标头时会抛出异常:

Content-Type: multipart/mixed; boundary=----=_IMSS7_NDR_MIME_Boundary

Having checked out the source code for the mail.jar library (version 1.4.5) the exception I'm getting is thrown from the javax.mail.internet.ParameterList(String s) constructor - the headers don't seem to get tokenized as I'd expect, it looks like the EQUALS SIGN after the four HYPHENS is causing a problem, since if I remove it and change the boundary to ----_IMSS7_NDR_MIME_Boundary the message parses fine. 签出mail.jar库(版本1.4.5)的源代码后,从javax.mail.internet.ParameterList(String s)构造函数中抛出了我正在获取的异常-头似乎没有被标记化就像我期望的那样,看起来好像四个HYPHENS引起了问题之后的EQUALS SIGN,因为如果我将其删除并将边界更改为----_IMSS7_NDR_MIME_Boundary则消息可以很好地解析。

Is this a bug in Javamail or my mail server? 这是Javamail还是我的邮件服务器中的错误? I'm thinking the latter since running the mail through an IETF validator http://tools.ietf.org/tools/msglint/ it tells me there is an error on the Content-Type line. 我正在考虑使用后者,因为它是通过IETF验证程序http://tools.ietf.org/tools/msglint/运行邮件的,它告诉我Content-Type行上存在错误。 If it is a bug in Postfix, is there any way to fix it? 如果它是Postfix中的错误,有什么办法可以解决?

Yes, it's a bug in the program that created the message. 是的,这是创建消息的程序中的错误。 That's probably not your mail server. 那可能不是您的邮件服务器。 Try setting the System property "mail.mime.parameters.strict" to "false". 尝试将系统属性“ mail.mime.parameters.strict”设置为“ false”。 See more on properties here . 此处查看有关属性的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM