Mailer.php
[Pman.Core] / Mailer.php
index 30de1c6..9daa52a 100644 (file)
@@ -455,16 +455,25 @@ class Pman_Core_Mailer {
     
     function htmlbodyInlineCss($html)
     {
+        print_R($html);exit;
         $dom = new DOMDocument();
         
         @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
         
-        $body = $dom->getElementsByTagName('body');
-        print_R($body);exit;
+        $html = $dom->getElementsByTagName('html');
+        $head = $dom->getElementsByTagName('head');
+        $body = $dom->getElementsByTagName('head');
+        
+        if(!$head->length){
+            $head = $dom->createElement('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->appendChild($s);
+        $head->item(0)->appendChild($s);
         
         return $dom->saveHTML();
     }