Jest kod poniżej który ładnie wysyła maila HTML. Wyciąga i dołącza obrazki też bardzo ładnie. Natomiast nie wyświetla tych obrazków w tresci maila. Próbuję coś takiego
//$mime->id = 'cid_'.md5_file($url);//generate a unique CID
//$this->setBodyHtml(str_replace("/$file",'cid:'.$at->id,$this->getBodyHtml(true)),'UTF-8',Zend_Mime::ENCODING_8BIT);
$html = str_replace($url, 'cid:'.$pathinfo['basename'] ,$html);
ale to nie idzie : ( może ktoś ma doświadczenie z tym. Obrazki w poczcie są ale się nie podstawiają : (
require_once 'Zend/Loader.php';
require_once 'Zend/Http/Client.php';
require_once 'Zend/Mail.php';
class Techi_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)
{
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);
$response = $image_http->request();
if ($response->getStatus() == 200)
{
$image_content = $response->getBody();
$mime_type = $response->getHeader('Content-Type');
$mime = new Zend_Mime_Part($image_content);
$mime->id = $url;
$mime->location = $url;//pathinfo['basename'];
$mime->type = $mime_type;
$mime->disposition = Zend_Mime::DISPOSITION_INLINE;
$mime->encoding = Zend_Mime::ENCODING_BASE64;
$mime->filename = $pathinfo['basename'];
//$mime->id = 'cid_'.md5_file($url);//generate a unique CID
//$this->setBodyHtml(str_replace("/$file",'cid:'.$at->id,$this->getBodyHtml(true)),'UTF-8',Zend_Mime::ENCODING_8BIT);
$html = str_replace($url, 'cid:'.$pathinfo['basename'] ,$html); $this->addAttachment($mime);
}
}
}
//dd($html);
return parent::setBodyHtml($html, $charset, $encoding);
}
}