Initial Commit

This commit is contained in:
GiacomoHome
2021-09-17 12:41:45 +02:00
commit 9001e4656e
570 changed files with 31013 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
<?php
class App_Model_Mail extends Zend_Mail
{
/**
* Sets the HTML body for the message
*
* @param string $html
* @param string $charset
* @param string $encoding
* @return Zend_Mail Provides fluent interface
*/
public function setBodyHtml($html, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE, $preload_images = true)
{
$preload_images = false;
try {
if ($preload_images) {
$this->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);
}
}