DataObjects/Core_group.php
[Pman.Core] / Mailer.php
index ef82bed..c4dce68 100644 (file)
@@ -321,14 +321,8 @@ class Pman_Core_Mailer {
         
         $pg = $ff->page;
         
-        $ts = microtime(true);
-        
         $email = is_array($email)  ? $email : $this->toData();
         
-        $diff = microtime(true) - $ts;
-        
-        print_r($diff);exit;
-        
         if (is_a($email, 'PEAR_Error')) {
             $pg->addEvent("COREMAILER-FAIL",  false, "email toData failed"); 
       
@@ -392,6 +386,8 @@ class Pman_Core_Mailer {
         @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
         $imgs= $dom->getElementsByTagName('img');
         
+        $urls = array();
+        
         foreach ($imgs as $i=>$img) {
             $url  = $img->getAttribute('src');
             if (preg_match('#^cid:#', $url)) {
@@ -402,16 +398,18 @@ class Pman_Core_Mailer {
                 continue;
             }
             
-            $conv = $this->fetchImage($url);
-            $this->images[$conv['contentid']] = $conv;
+            if(!array_key_exists($url, $urls)){
+                $conv = $this->fetchImage($url);
+                $urls[$url] = $conv;
+                $this->images[$conv['contentid']] = $conv;
+            } else {
+                $conv = $urls[$url];
+            }
             
             $img->setAttribute('src', 'cid:' . $conv['contentid']);
-            
-            
         }
-        return $dom->saveHTML();
-        
         
+        return $dom->saveHTML();
         
     }
     function htmlbodyCssEmbed($html)