in commons-email2-javax/src/main/java/org/apache/commons/mail2/javax/Email.java [1686:1713]
public void updateContentType(final String contentType) {
if (EmailUtils.isEmpty(contentType)) {
this.contentType = null;
} else {
// set the content type
this.contentType = contentType;
// set the charset if the input was properly formed
final String strMarker = "; charset=";
int charsetPos = EmailUtils.toLower(contentType).indexOf(strMarker);
if (charsetPos != -1) {
// find the next space (after the marker)
charsetPos += strMarker.length();
final int intCharsetEnd = EmailUtils.toLower(contentType).indexOf(" ", charsetPos);
if (intCharsetEnd != -1) {
this.charset = contentType.substring(charsetPos, intCharsetEnd);
} else {
this.charset = contentType.substring(charsetPos);
}
} else if (this.contentType.startsWith("text/") && EmailUtils.isNotEmpty(this.charset)) {
// use the default charset, if one exists, for messages
// whose content-type is some form of text.
final StringBuilder contentTypeBuf = new StringBuilder(this.contentType);
contentTypeBuf.append(strMarker);
contentTypeBuf.append(this.charset);
this.contentType = contentTypeBuf.toString();
}
}
}