Mailer.php
[Pman.Core] / Mailer.php
index 86dcf28..92f8b5c 100644 (file)
@@ -111,7 +111,7 @@ class Pman_Core_Mailer {
         $templateFile = $this->template;
         $args = (array)$this->contents;
         $content  = clone($this->page);
-        print_R($content);exit;
+        
         foreach($args as $k=>$v) {
             $content->$k = $v;
         }
@@ -179,7 +179,7 @@ class Pman_Core_Mailer {
             if ($this->css_embed) {
                 $htmlbody = $this->htmlbodyCssEmbed($htmlbody);
             }
-            print_r($this);exit;
+            
             if ($this->css_inline && strlen($this->css_inline)) {
                 $htmlbody = $this->htmlbodyInlineCss($htmlbody);
             }
@@ -459,12 +459,19 @@ class Pman_Core_Mailer {
         
         @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
         
-        $body = $dom->getElementsByTagName('body');
+        $html = $dom->getElementsByTagName('html');
+        
+        $head = $dom->getElementsByTagName('head');
+        
+        if(!$head->length){
+            $head = $dom->createElement('head');
+            $html->item(0)->appendChild($head);
+        }
         
         $s = $dom->createElement('style');
         $e = $dom->createTextNode($this->css_inline);
         $s->appendChild($e);
-        $body->appendChild($s);
+        $body->item(0)->appendChild($s);
         
         return $dom->saveHTML();
     }