Comming back to the thread
It is closed and I can not answer there, so I start a new one. It is already a year old, and I was thinking that maybe some solution could have been implemented.
I have found the property
In some cases JavaMail is unable to process messages with an invalid Content-Type header. The header may have incorrect syntax or other problems. This property specifies the name of a class that will be used to clean up the Content-Type header value before JavaMail uses it. The class must have a method with this signature:
Is there already a class to clean up the Content-Type? Or do you have more ideas to deal with this problem? Or ignore problematic headers?
As in the mentioned question is said, the problem is that the header comes in this way
Content-Type: text/rfc822-headers; Content-Transfer-Encoding: 8bit
Which would be correct.
Have you contacted the owner of the mailer creating this garbage? That's really the place to start.
I'm not aware of any existing classes to do this cleanup. If this is the only kind of bad header that you need to deal with it should be straightforward to create your own class that handles just this case.
Thanks for your answer. These emails are comming from different domains (3 that I have seen). Since I don´t know whether there are more or not (probably there are), having a solution in our system would be the best option.
Another problem: so far this has been the only problematic header I need to deal with, but maybe tomorrow comes another one. That means that my class should be expanded. Since mail.mime.contenttypehandler property exists, I assume that I am not the only one who is dealing with this issue, maybe someone has more experience that I do and could give me a hand??
Can you send me an example message that has this problem? (As an attachment, to email@example.com.)
I'm not sure which part of the contenttypehandler you think is difficult. Do you understand how to write the class and the method, but don't understand what to put in the method? Just look for the string "; Content-Transfer-Encoding:" in the content type string and remove it and everything after it.