Mail app only shows plain text, no html

HI there,

I could use some help troubleshooting why the mail app on my nextcloud server does not display html formatted email, but only plain text. If there is a switch or config somewhere I am obviously not aware of it.
Checking the logs, the following turns up a lot:
[PHP] Error: Undefined property: DOMComment::$data at /var/www/cloud/apps/mail/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php#216
And it seems this is related to the news-app, which I disabled and removed a long time ago. I don’t want to indiscriminately delete that code, as I don’t know what else might be dependent on it.

Any advice?

If the code was deleted then it shouldn’t cause any problems.

What version of Mail do you use?

Hallo Cristoph, und Danke für dein Antwort!

I’m on NC 18.0.3 and Mail 1.1.4, though the problem was there in at least the two previous versions as well. I’d been trying to figure it out for myself, but this is a bit out of my depth…
Anything I can do to provide more information?



You could open the browser dev console and check if the message body is loaded. It’s an URL ending with /html. That will be loaded into an iframe.

Otherwise also check your data/nextcloud.log for more info on the error.

I think the message body is loaded, but it isn’t rendered. I see many table rows an data decalrations, but all of them empty (this is a pure html message that renders perfectly in TBirdSchermafdruk van 2020-04-14 18-18-38

Is this originally a message with dark background and white text? Is there any text in the HTML?

Lots of text and pictures in there. I’ll make a screenshot and save the email as a file for you if you want them. Actually the mail was a light background overall, with different backgrounds (some aof them pictures) in the table cells. I deliberately took a complicated one as an example, but simple ones don’t work either. Simple links don’t work.

Schermafdruk van 2020-04-15 09-40-04

email contents:

Just upgraded to 1.3.2, but this did not help. Iḿ getting the same errors. After the upgrade I switched to the app and because I immediately noticed html wasn’t displayed switched to the logs. These turn up:

[PHP] Error: Undefined property: DOMComment::$data at /var/www/cloud/apps/mail/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php#216

GET /index.php/apps/mail/api/accounts/2/folders/SU5CT1g%3D/messages/10636/html
from by martin at 2020-04-17T11:25:49+00:00

and, more frequently:

[PHP] Error: Undefined property: DOMAttr::$name at /var/www/cloud/apps/mail/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php#267

GET /index.php/apps/mail/api/accounts/2/folders/SU5CT1g%3D/messages/10636/html
from by martin at 2020-04-17T11:25:49+00:00PHP

Now I’ll try deleting the app and then reinstalling it.

Done, but did not help. I am getting the exact same errors. Anybody else struggling with this? What exactly is this “htmlpurifier” intended to do?

This never helps. You’ll end up with the same state as before.

It purifies the HTML bodies of messages before we show them in the browser.

It “purifies” a bit too much in this case, I would think…
What else can I do/look for? It apparently has trouble with two undefined variables, ‘data’ and ‘name’, which happens in these two functions:

protected function createStartNode($node, &$tokens, $collect, $config)
// intercept non element nodes. WE MUST catch all of them,
// but we’re not getting the character reference nodes because
// those should have been preprocessed
if ($node->nodeType === XML_TEXT_NODE) {
$data = $this->getData($node); // Handle variable data property
if ($data !== null) {
$tokens[] = $this->factory->createText($data);
return false;
} elseif ($node->nodeType === XML_CDATA_SECTION_NODE) {
// undo libxml’s special treatment of and tags
$last = end($tokens);
$data = $node->data;
// (note $node->tagname is already normalized)
if ($last instanceof HTMLPurifier_Token_Start && ($last->name == ‘script’ || $last->name == ‘style’)) {
$new_data = trim($data);
if (substr($new_data, 0, 4) === ‘’) {
$data = substr($data, 0, -3);
} else {
// Highly suspicious! Not sure what to do…
$tokens[] = $this->factory->createText($this->parseText($data, $config));
return false;
} elseif ($node->nodeType === XML_COMMENT_NODE) {
// this is code is only invoked for comments in script/style in versions
// of libxml pre-2.6.28 (regular comments, of course, are still
// handled regularly)
$tokens[] = $this->factory->createComment($node->data); <<<<<< This is line 216------------------
return false;
} elseif ($node->nodeType !== XML_ELEMENT_NODE) {
// not-well tested: there may be other nodes we have to grab
return false;
$attr = $node->hasAttributes() ? $this->transformAttrToAssoc($node->attributes) : array();
$tag_name = $this->getTagName($node); // Handle variable tagName property
if (empty($tag_name)) {
return (bool) $node->childNodes->length;
// We still have to make sure that the element actually IS empty
if (!$node->childNodes->length) {
if ($collect) {
$tokens[] = $this->factory->createEmpty($tag_name, $attr);
return false;
} else {
if ($collect) {
$tokens[] = $this->factory->createStart($tag_name, $attr);
return true;

protected function transformAttrToAssoc($node_map)
// NamedNodeMap is documented very well, so we’re using undocumented
// features, namely, the fact that it implements Iterator and
// has a ->length attribute
if ($node_map->length === 0) {
return array();
$array = array();
foreach ($node_map as $attr) {
$array[$attr->name] = $attr->value; <<<<<<<This is line 267-------------
return $array;

The error in line 267 happens loads of times, the one in 216 only seldom.

As i remember .eml has no HTML body. This is an outdated Outlook / Outlook express e-mail format.

Nope. Saved this one from Thunderbird, and it’s html all right:

=0A<html xmlns=3D"http://www.=">=0A=0A<meta http-equiv=3D"Content-Type" content=3D=
“text/html; charset=3Dutf-8” />=0A<meta http-equiv=3D"X-UA-Compatible" cont=
ent=3D"IE=3Dedge" />=0A<meta name=3D"viewport" content=3D"width=3Ddevice-wi

No suggestions? At all?

I’m very sorry that we can not offer you 24/7 support for free. It will take time until someone is able to reproduce the problem. Or you just dig deeper and fix it yourself. Pull requests with fixes are always welcome :slight_smile:

You don’t have to apologize. At all. I’m sorry if you felt I was being inappropriate.
Please know I appreciate whatever you can point me to. Also, I hope you realize we’re not all developers. I’ll do what I can myself, but I’m out of my depth here with something I’d really like to get working.

1 Like