The "htmlspecialchars" was butchering the entites-encoded output provided by the decodeHeader(). E.g. if there was any non-ascii characters in the "From:" line, the decodeHeader would return them as entities, "&#NNNN;&#NNNN;....", and htmlspecialchars would reduce this to "&#NNNN;&#NNNN...." which looked EXTRAORDINARILY ugly when rendered in a browser. This is a stop-gap measure -- htmlspecialchars should be called at some point.