I have a self written Java mail client, that reads messages from mail server.
I did not have any problem with it, but recently I found an exception, when this client tried to read one complicated email message. The stack trace says, that encoding 'quoted/printable' is unknown, and probably this information is enough to find the solution.
Anyway, I'll complete the question and put the log here:
java.io.IOException: Unknown encoding: quoted/printable
at javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:113)
at com.sun.mail.handlers.text_plain.getContent(text_plain.java:107)
at javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:790)
at javax.activation.DataHandler.getContent(DataHandler.java:537)
at javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:644)
Here's message part, containing this encoding information
--=_374450e655545f2af979375837b3e516
Content-Transfer-Encoding: quoted/printable
Content-Type: text/plain; charset=utf-8
Rest of information is some thml-formatted text.
So, is there a way to solve the problem without changing the javax.mail provider/version ? Now I'm using
group: 'com.sun.mail', name: 'javax.mail', version: '1.5.1'
Or maybe I just misunderstood the problem and I should solve it another way?
Whatever mailer created that message is broken. Please report the problem to the owner of that mailer. The correct name is "quoted-printable", not "quoted/printable".
Most often such errors are the result of amateurs writing spam mailers without bothering to read the RFCs first.
You can set the System property "mail.mime.ignoreunknownencoding" to "true" to have JavaMail simply ignore the error and not try to decode the data. You can also catch the exception, use the getEncoding method to get the value of the header, and try to guess what the sender had in mind, then use the getRawInputStream method and decode the data yourself.