var $bcc = false;
+ var $body_cls = false;
+
function __construct($args) {
foreach($args as $k=>$v) {
// a bit trusting..
// for the html body, we may want to convert the attachments to images.
// var_dump($htmlbody);exit;
+
+ if(!empty($content->body_cls) && strlen($content->body_cls)){
+ $htmlbody = $this->htmlbodySetClass($htmlbody, $content->body_cls);
+ }
+
if ($this->replaceImages) {
$htmlbody = $this->htmlbodytoCID($htmlbody);
}
@$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)) {
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();
*/
}
+ function htmlbodySetClass($html, $cls)
+ {
+ $dom = new DOMDocument();
+
+ @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+
+ $body = $dom->getElementsByTagName('body');
+
+ $class = $dom->createAttribute('class');
+ $class->value = $cls;
+ $body->item(0)->appendChild($class);
+
+ return $dom->saveHTML();
+ }
+
function fetchImage($url)
{