X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Mailer.php;h=23fb87582797ad3745dc1c904e95e84ed89847f5;hb=b341a92085a9d4a5cfb1d2043e599420472aa6c8;hp=881a9fedb90e68163e41cfb7389e71e5f75bdd36;hpb=dd883fa29734a4d3031e6ab1ca146ca09a744aec;p=Pman.Core diff --git a/Mailer.php b/Mailer.php index 881a9fed..23fb8758 100644 --- a/Mailer.php +++ b/Mailer.php @@ -171,7 +171,7 @@ class Pman_Core_Mailer { // for the html body, we may want to convert the attachments to images. // var_dump($htmlbody);exit; - if($content->body_cls && strlen($content->body_cls)){ + if(!empty($content->body_cls) && strlen($content->body_cls)){ $htmlbody = $this->htmlbodySetClass($htmlbody, $content->body_cls); } @@ -373,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; @@ -386,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)) { @@ -396,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) @@ -499,11 +506,16 @@ 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->appendChild($class); + return $dom->saveHTML(); } function fetchImage($url)