diff --git a/data/web/inc/ajax/qitem_details.php b/data/web/inc/ajax/qitem_details.php index 801fd3d0..fedca73b 100644 --- a/data/web/inc/ajax/qitem_details.php +++ b/data/web/inc/ajax/qitem_details.php @@ -40,6 +40,13 @@ if (!empty($_GET['id']) && ctype_alnum($_GET['id'])) { $data['text_plain'] = $mail_parser->getMessageBody('text'); // Get html content and convert to text $data['text_html'] = $html2text->convert($mail_parser->getMessageBody('html')); + if (empty($data['text_plain']) && empty($data['text_html'])) { + // Failed to parse content, try raw + $text = trim(substr($mailc['msg'], strpos($mailc['msg'], "\r\n\r\n") + 1)); + // Only return html->text + $data['text_plain'] = 'Parser failed, assuming HTML'; + $data['text_html'] = $html2text->convert($text); + } (empty($data['text_plain'])) ? $data['text_plain'] = '-' : null; // Get subject $data['subject'] = $mail_parser->getHeader('subject');