HTML emails are sent as text

if you have an email template that starts with a valid html declaration like

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "">

the content type is considered as text. The problem resides in the EmailSender#getContentBodyType method:

if (text.trim().startsWith("<html>")) {
     bodyContentType = "text/html; charset=UTF-8";
} else {
     bodyContentType = "text/plain; charset=UTF-8";

this IMHO a too simplistic approach to determine a message’s content type.

A more reliable solution would be refactoring emailing methods, to be able to specify content type explicitly.


1 Like

Agree. Created issue: