Mailer.php
[Pman.Core] / Mailer.php
index 3588ee4..832b6b9 100644 (file)
@@ -386,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)) {
@@ -396,13 +398,36 @@ 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']);
+        }
+        
+        /*
+        foreach ($imgs as $i=>$img) {
+            $url  = $img->getAttribute('src');
+            if (preg_match('#^cid:#', $url)) {
+                continue;
+            }
+            $me = $img->getAttribute('mailembed');
+            if ($me == 'no') {
+                continue;
+            }
             
+            $conv = $this->fetchImage($url);
+            $this->images[$conv['contentid']] = $conv;
             
+            $img->setAttribute('src', 'cid:' . $conv['contentid']);
         }
+        * 
+        */
+        
         return $dom->saveHTML();