Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

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.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.