forked from Wavyzz/dolibarr
Fix: If duplicate images are embedded, they may show up as attachments, so remove them.
This commit is contained in:
@@ -135,14 +135,19 @@ class simplemail {
|
||||
|
||||
function writeattachement(&$attachement,$B) {
|
||||
$message = '';
|
||||
$inline = array();
|
||||
if ( !empty($attachement) ) {
|
||||
foreach($attachement as $AttmFile){
|
||||
$patharray = explode ("/", $AttmFile['filename']);
|
||||
$FileName = $patharray[count($patharray)-1];
|
||||
|
||||
// If duplicate images are embedded, they may show up as attachments, so remove them.
|
||||
if (!in_array($AttmFile['filename'],$inline))
|
||||
{
|
||||
$message .= "\n--".$B."\n";
|
||||
|
||||
if (!empty($AttmFile['cid'])) {
|
||||
$inline[] = $AttmFile['filename'];
|
||||
$message .= "Content-Type: {$AttmFile['contenttype']};\n name=\"".$FileName."\"\n";
|
||||
$message .= "Content-Transfer-Encoding: base64\n";
|
||||
$message .= "Content-ID: <{$AttmFile['cid']}>\n";
|
||||
@@ -161,6 +166,7 @@ class simplemail {
|
||||
$message .= $FileContent;
|
||||
$message .= "\n\n";
|
||||
}
|
||||
}
|
||||
$message .= "\n--".$B."--\n";
|
||||
}
|
||||
return $message;
|
||||
|
||||
@@ -895,15 +895,19 @@ class CMailFile
|
||||
|
||||
if (!empty($this->html_images))
|
||||
{
|
||||
// If duplicate images are embedded, they may show up as attachments, so remove them.
|
||||
//$html_images = array_unique($this->html_images);
|
||||
//sort($html_images);
|
||||
$inline = array();
|
||||
|
||||
$i=0;
|
||||
|
||||
foreach ($this->html_images as $img)
|
||||
{
|
||||
// Read imahe file
|
||||
if ($image = file_get_contents($images_dir.'/'.$img["name"]))
|
||||
$fullpath = $images_dir.'/'.$img["name"];
|
||||
|
||||
// If duplicate images are embedded, they may show up as attachments, so remove them.
|
||||
if (!in_array($fullpath,$inline))
|
||||
{
|
||||
// Read image file
|
||||
if ($image = file_get_contents($fullpath))
|
||||
{
|
||||
// On garde que le nom de l'image
|
||||
eregi('([A-Za-z0-9_-]+[.]?[A-Za-z0-9]+)?$',$img["name"],$regs);
|
||||
@@ -914,6 +918,8 @@ class CMailFile
|
||||
$this->images_encoded[$i]['cid'] = $img["cid"];
|
||||
// Encodage de l'image
|
||||
$this->images_encoded[$i]["image_encoded"] = chunk_split(base64_encode($image), 68, $this->eol);
|
||||
$inline[] = $fullpath;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user