Permalink
Browse files

silent html2text conversion

  • Loading branch information...
maskas committed Sep 16, 2014
1 parent a601995 commit f5bb4e40fe21c9e31c64f5e12ef89841f9db3822
Showing with 14 additions and 2 deletions.
  1. +6 −1 Ip/Internal/Email/Module.php
  2. +8 −1 Ip/Internal/Text/Html2Text.php
@@ -186,7 +186,12 @@ function send()
$mail->IsHTML(true); // send as HTML
$mail->MsgHTML($email['email']);
$mail->AltBody = \Ip\Internal\Text\Html2Text::convert($email['email']);
try {
$altBody = \Ip\Internal\Text\Html2Text::convert($email['email']);
} catch (\Ip\Internal\Text\Html2TextException $e) {
$altBody = $email['email'];
}
$mail->AltBody = $altBody;
} else {
/*$h2t = new \Ip\Internal\Text\Html2Text($content, false);
$mail->Body = $h2t->get_text();*/
@@ -47,11 +47,18 @@ class Html2Text
*/
public static function convert($html)
{
if ($html == '') {
return '';
}
$html = self::fix_newlines($html);
$doc = new \DOMDocument();
if (!$doc->loadHTML($html))
$prevValue = libxml_use_internal_errors(true);
$loaded = $doc->loadHTML($html);
libxml_use_internal_errors($prevValue);
if (!$loaded) {
throw new Html2TextException("Could not load HTML - badly formed?", $html);
}
$output = self::iterate_over_node($doc);

0 comments on commit f5bb4e4

Please sign in to comment.