[Building Sakai] junk in email messages

Charles Hedrick hedrick at rutgers.edu
Tue Jan 31 13:21:46 PST 2012


We had a complain that announcements containing special characters, e.g.  , show up with garbage characters in the plaintext version.

Looking at it, &nbsp turns into the correct NS character. However MyMessage in BasicEmailService checks to see whether all the characters can be handled with ISO_8859_1. They can, because it has NS. We then call 

                                                    bodyPart.setContent(partText.toString(), mimeType);

using a Mime type of text/plain; charset=iso-8859-1. Unfortunately it appears that the Java mail mechanism doesn't actually use the charset here (and even using setText didn't help). It outputs UTF-8. However since the header claims ISO-8859-1, the mail program displays it incorrectly.

In theory it makes sense to use 8859 rather than UTF_8 where possible. But the Java mail code seems almost intentionally designed to make it impossible to get this right. I get buried in layers of objects with ill-defined properties. Does anyone know the BasicEmailService well enough to see what's going on?




More information about the sakai-dev mailing list