From 84491bfbdd5a45e871bcc2d213beaabb0980d598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 8 Jun 2024 12:00:23 +0200 Subject: [PATCH] fix inline images with swiftmailer (#29923) --- htdocs/core/class/CMailFile.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 84d04c38138..f444f5fc46f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -709,6 +709,14 @@ class CMailFile } if ($this->atleastoneimage) { + foreach ($this->html_images as $img) { + // $img['fullpath'],$img['image_encoded'],$img['name'],$img['content_type'],$img['cid'] + $attachment = Swift_Image::fromPath($img['fullpath']); + // embed image + $imgcid = $this->message->embed($attachment); + // replace cid by the one created by swiftmail in html message + $msg = str_replace("cid:".$img['cid'], $imgcid, $msg); + } foreach ($this->images_encoded as $img) { //$img['fullpath'],$img['image_encoded'],$img['name'],$img['content_type'],$img['cid'] $attachment = Swift_Image::fromPath($img['fullpath']);