How does the IMAP/POP3 module define wheter a mail is HTML or no?

0
We are using the IMAP/POP3 module for a customer service application. Not all customers send information through proper mail clients, so sometimes the email is not HTML encoded. To solve this I conditionally show either a FormatStringWidget for the HTML = true and a normal string field for HTML = false and this seems to work fine. However today we received an email which has HTML = true, however the content of the mail has no HTML tags whatsoever, making the display off this email very messy (as all formatting is removed). Is there any way to check/change this behaviour? Or should I manually start checking if the content of the mail actually has HTML tags.
asked
2 answers
0

Looks like the code uses:

javax.mail.Message.isMimeType("text/html")

So it's relying on the MIME type of the email to be set correctly. Sounds like you got an incorrectly formatted email, so the only workaround I see is checking the contents manually.

answered
0

Something else to think about: when displaying html from an external source you open yourself up to attacks from malicious code inside this html. So it seems to be worth to at least try sanitising the html using antisamy before displaying it.

On the original question; interesting that there would still be email clients nowadays doing this wrong. I guess manually checking the content for any html tags will provide a workaround 95% of the time.

answered