Issue Reading Some Emails in SuiteCRM - PHP Fatal Error (HtmlSanitizer)

Dear All,

I have successfully installed a SuiteCRM instance and configured both inbound and outbound email accounts. I can see the list of emails in my INBOX, and for most of the emails, everything works correctly. However, I’ve encountered an issue with some emails.

When I try to read or link certain emails, instead of displaying the email content, I receive the following error message:

[Fri Jan 17 09:59:15.410790 2025] [php:error] [pid 53899:tid 53899] [client 192.168.160.253:58670] PHP Fatal error:  Uncaught TypeError: SuiteCRM\\HtmlSanitizer::clean(): 
Argument #1 ($dirtyHtml) must be of type string, null given, 
called in /var/www/suitecrm/public/legacy/include/HtmlSanitizer.php on line 116 and 
defined in /var/www/suitecrm/public/legacy/include/HtmlSanitizer.php:142\n

Stack trace:
#0 /var/www/suitecrm/public/legacy/include/HtmlSanitizer.php(116): SuiteCRM\\HtmlSanitizer->clean()\n
#1 /var/www/suitecrm/public/legacy/modules/InboundEmail/InboundEmail.php(4154): SuiteCRM\\HtmlSanitizer::cleanHtml()\n
#2 /var/www/suitecrm/public/legacy/modules/InboundEmail/InboundEmail.php(5818): InboundEmail->getMessageTextWithUid()\n
#3 /var/www/suitecrm/public/legacy/modules/Emails/include/DetailView/EmailsNonImportedDetailView.php(89): InboundEmail->returnNonImportedEmail()\n
#4 /var/www/suitecrm/public/legacy/modules/Emails/views/view.detailnonimported.php(77): EmailsNonImportedDetailView->populateBean()\n
#5 /var/www/suitecrm/public/legacy/include/MVC/View/SugarView.php(208): EmailsViewDetailNonImported->preDisplay()\n
#6 /var/www/suitecrm/public/legacy/include/MVC/Controller/SugarController.php(432): SugarView->process()\n
#7 /var/www/suitecrm/public/legacy/include/MVC/Controller/SugarController.php(363): SugarController->processView()\n
#8 /var/www/suitecrm/public/legacy/include/MVC/SugarApplication.php(101): SugarController->execute()\n
#9 /var/www/suitecrm/public/legacy/index.php(52): SugarApplication->execute()\n
#10 {main}\n  thrown in /var/www/suitecrm/public/legacy/include/HtmlSanitizer.php on line 142, referer: https://crm.ciholo.com/

This error only occurs with certain emails, while others display without any problems.

Question:

Does anyone have any ideas about what might be causing this issue or how I could debug/fix it?
I’d appreciate any advice or insights!

Maybe helpful:


Check it on SuiteCRM GitHub issues: