user1605747
user1605747

Reputation: 11

com.sun.mail.util.DecodingException: BASE64Decoder: Error in encoded stream retrieving mail from Yahoo

I've been helped so much by StackOverflow, so wanted to post this to save others the hours I spent debugging it:

I'm using a Java application to retrieve mail via IMAP/SSL. Fine for months. Now problems with a specific message from Yahoo. The message is multipart/alternative with a base64-encoded text/plain part and a base64-encoded text/html part.

Retrieval fails with:

IOException: com.sun.mail.util.DecodingException: BASE64Decoder: Error in encoded stream: needed 4 valid base64 characters but only got 3 before EOF, the 10 most recent characters were: "IPONREPLY>" :[com.sun.mail.util.BASE64DecoderStream.decode(BASE64DecoderStream.java:256), com.sun.mail.util.BASE64DecoderStream.read(BASE64DecoderStream.java:110)...

The content itself looks normal using Yahoo's webmail client. Looking at what is retrieve by my application in the HTML part, I see at the end of the base64-encoded text/html part:

[...]
YWdlcy9iank1LzQ5NjViOGUyLTQxYjEtNGFhNi1iOGFhLTEzNGQwYjYxMWM5My5naWZ4IiAvPg0K
DQo8L2JvZHk+PC9odG1sPg==
<XHTML-STRIPONREPLY>                                                                               


                 </XHTML-STRIPONREPLY>

This is text that Yahoo recently started adding to messages. It works with text that is not encoded or uses quoted-printable encoding, but breaks base64-encoded parts.

I filed a report with Yahoo, so hope they will fix this soon.

Upvotes: 1

Views: 3437

Answers (1)

leocborges
leocborges

Reputation: 4837

Try set your properties with:

properties.setProperty("mail.imaps.partialfetch", "false");

Upvotes: 0

Related Questions