setType(Zend_Mime::MULTIPART_RELATED); $dom = new DOMDocument(null, $this->getCharset()); @$dom->loadHTML($html); $images = $dom->getElementsByTagName('img'); for ($i = 0; $i < $images->length; $i++) { $img = $images->item($i); $url = $img->getAttribute('src'); $image_http = new Zend_Http_Client($url); $image_http->setAdapter('Zend_Http_Client_Adapter_Curl'); $response = $image_http->request(); if ($response->getStatus() == 200) { $image_content = $response->getBody(); $pathinfo = pathinfo($url); $mime_type = $response->getHeader('Content-Type'); $mime = new Zend_Mime_Part($image_content); $mime->id = $url; $mime->location = $url; $mime->type = $mime_type; $mime->disposition = Zend_Mime::DISPOSITION_INLINE; $mime->encoding = Zend_Mime::ENCODING_BASE64; $mime->filename = $pathinfo['basename']; $this->addAttachment($mime); } } } } catch (ZendException $e) { Zend_Registry::get('error_log')->setEventItem('url', $this->getRequest()->getRequestUri())->setEventItem('trace', Zend_Json::encode($e->getTrace()))->setEventItem('params', Zend_Json::encode($this->getRequest()->getParams()))->info($e->getMessage()); } return parent::setBodyHtml($html, $charset, $encoding); } }