Mailer.php
[Pman.Core] / Mailer.php
index 3e9a353..8d0be13 100644 (file)
@@ -380,7 +380,7 @@ class Pman_Core_Mailer {
     {
         $dom = new DOMDocument();
         // this may raise parse errors as some html may be a component..
-        @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+        @$dom->loadHTML($html);
         $imgs= $dom->getElementsByTagName('img');
         
         foreach ($imgs as $i=>$img) {
@@ -411,7 +411,7 @@ class Pman_Core_Mailer {
         $dom = new DOMDocument();
         
         // this may raise parse errors as some html may be a component..
-        @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+        @$dom->loadHTML($html);
         $links = $dom->getElementsByTagName('link');
         $lc = array();
         foreach ($links as $link) {  // duplicate as links is dynamic and we change it..!
@@ -455,24 +455,26 @@ class Pman_Core_Mailer {
     
     function htmlbodyInlineCss($html)
     {
+        print_R($html);exit;
+        
         $dom = new DOMDocument();
         
-        @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+        @$dom->loadHTML($html);
         
         $html = $dom->getElementsByTagName('html');
-        
         $head = $dom->getElementsByTagName('head');
+        $body = $dom->getElementsByTagName('head');
         
         if(!$head->length){
             $head = $dom->createElement('head');
-            $html->item(0)->appendChild($head);
+            $html->item(0)->insertBefore($head, $body->item(0));
             $head = $dom->getElementsByTagName('head');
         }
         
         $s = $dom->createElement('style');
         $e = $dom->createTextNode($this->css_inline);
         $s->appendChild($e);
-        $body->item(0)->appendChild($s);
+        $head->item(0)->appendChild($s);
         
         return $dom->saveHTML();
     }