File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,12 @@ function send()
186186 $ mail ->IsHTML (true ); // send as HTML
187187
188188 $ mail ->MsgHTML ($ email ['email ' ]);
189- $ mail ->AltBody = \Ip \Internal \Text \Html2Text::convert ($ email ['email ' ]);
189+ try {
190+ $ altBody = \Ip \Internal \Text \Html2Text::convert ($ email ['email ' ]);
191+ } catch (\Ip \Internal \Text \Html2TextException $ e ) {
192+ $ altBody = $ email ['email ' ];
193+ }
194+ $ mail ->AltBody = $ altBody ;
190195 } else {
191196 /*$h2t = new \Ip\Internal\Text\Html2Text($content, false);
192197 $mail->Body = $h2t->get_text();*/
Original file line number Diff line number Diff line change @@ -47,11 +47,18 @@ class Html2Text
4747 */
4848 public static function convert ($ html )
4949 {
50+ if ($ html == '' ) {
51+ return '' ;
52+ }
5053 $ html = self ::fix_newlines ($ html );
5154
5255 $ doc = new \DOMDocument ();
53- if (!$ doc ->loadHTML ($ html ))
56+ $ prevValue = libxml_use_internal_errors (true );
57+ $ loaded = $ doc ->loadHTML ($ html );
58+ libxml_use_internal_errors ($ prevValue );
59+ if (!$ loaded ) {
5460 throw new Html2TextException ("Could not load HTML - badly formed? " , $ html );
61+ }
5562
5663 $ output = self ::iterate_over_node ($ doc );
5764
You can’t perform that action at this time.
0 commit comments