DataObjects/Core_watch.php
[Pman.Core] / Mailer.php
index 3a94034..8ae5336 100644 (file)
@@ -140,7 +140,9 @@ class Pman_Core_Mailer {
             
             // for the html body, we may want to convert the attachments to images.
 //            var_dump($htmlbody);exit;
-            $htmlbody = $this->htmlbodytoCID($htmlbody);
+            if ($this->replaceImages) {
+                $htmlbody = $this->htmlbodytoCID($htmlbody);    
+            }
             
               
         }
@@ -312,6 +314,9 @@ class Pman_Core_Mailer {
         
         foreach ($imgs as $i=>$img) {
             $url  = $img->getAttribute('src');
+            if (preg_match('#^cid:#', $url)) {
+                continue;
+            }
             $conv = $this->fetchImage($url);
             $this->images[$conv['contentid']] = $conv;
             
@@ -326,20 +331,15 @@ class Pman_Core_Mailer {
     }
     function fetchImage($url)
     {
-        print_r($url);exit;
+        
         if ($url[0] == '/') {
             $ff = HTML_FlexyFramework::get();
             $file = $ff->rootDir . $url;
-            print_r($file);
-            echo "<br/>";
             require_once 'File/MimeType.php';
             $m  = new File_MimeType();
             $mt = $m->fromFilename($file);
             $ext = $m->toExt($mt); 
-            print_r($mt);
-            echo "<br/>";
-            print_r($ext);
-            echo "<br/>";exit;
+            
             return array(
                     'mimetype' => $mt,
                    'ext' => $ext,
@@ -379,7 +379,7 @@ class Pman_Core_Mailer {
         
         $cache = ini_get('session.save_path')."/Pman_Core_Mailer-{$user}/" . md5($url);
         if (file_exists($cache) and filemtime($cache) > strtotime('NOW - 1 WEEK')) {
-            $ret =  json_decode($cache);
+            $ret =  json_decode(file_get_contents($cache), true);
             $ret['file'] = $cache . '.data';
             return $ret;
         }