X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Mailer.php;h=23fb87582797ad3745dc1c904e95e84ed89847f5;hb=b341a92085a9d4a5cfb1d2043e599420472aa6c8;hp=ef82bed7691cbfecf8ae7c7f46cc1c50502cfaa4;hpb=45c9d54c3752ca205e7f745107c8f66c8d4f549c;p=Pman.Core diff --git a/Mailer.php b/Mailer.php index ef82bed7..23fb8758 100644 --- a/Mailer.php +++ b/Mailer.php @@ -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"); @@ -379,7 +373,10 @@ class Pman_Core_Mailer { 'Subject: ' . @$email['headers']['Subject'] ); } else { - $pg->addEvent("COREMAILER-FAIL", false, $ret->toString()); + $pg->addEvent("COREMAILER-FAIL", false, + "Sending to : " . ( is_array($rcpts) ? implode(', ', $rcpts) : $rcpts ) . + " Error: " . $ret->toString()); + } return $ret; @@ -392,6 +389,8 @@ class Pman_Core_Mailer { @$dom->loadHTML('' .$html); $imgs= $dom->getElementsByTagName('img'); + $urls = array(); + foreach ($imgs as $i=>$img) { $url = $img->getAttribute('src'); if (preg_match('#^cid:#', $url)) { @@ -402,16 +401,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) @@ -505,10 +506,14 @@ class Pman_Core_Mailer { @$dom->loadHTML('' .$html); $body = $dom->getElementsByTagName('body'); + if (!empty($body->length)) { + $body->item(0)->setAttribute('class', $cls); + } else { + $body = $dom->createElement("body"); + $body->setAttribute('class', $cls); + $dom->appendChild($body); + } - $class = $dom->createAttribute('class'); - $class->value = $cls; - $body->item(0)->appendChild($class); return $dom->saveHTML(); }