[Web] Fall back to raw content when mail parsing fails, fixes #1892
parent
243c441ae1
commit
b8fe3f5fd4
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue