简体   繁体   中英

Javamail header parsing error

I'm using the Javamail library to retrieve messages from a Postfix email server. 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.

Is this a bug in Javamail or my mail server? 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. If it is a bug in Postfix, is there any way to fix it?

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". See more on properties here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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