From 2c734f90abc6363df31f6ec19e38f2b4a8f8565f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Yan?= Date: Sat, 26 Nov 2016 12:05:41 +0100 Subject: [PATCH 1/2] logo --- Mailer/Mailer.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Mailer/Mailer.php b/Mailer/Mailer.php index 7175f67..9611a69 100644 --- a/Mailer/Mailer.php +++ b/Mailer/Mailer.php @@ -97,6 +97,17 @@ public function setTemplate($templateName, array $vars = array()) $this->getMessage()->setReplyTo($template->renderBlock('reply_to', $vars)); } + if ($template->hasBlock('cid')) { + $body = $template->renderBlock('body', $vars); + $cids = explode(',', $template->renderBlock('cid', $vars)); + foreach ($cids as $key=>$cid) { + $img_data = file_get_contents($cid); + $cidToEmbed = $this->getMessage()->embed(\Swift_Image::newInstance($img_data, $key.'.png', mime_content_type($cid))); + $body = str_replace("{cid}[" . $key . "]", $cidToEmbed, $body); + } + $this->getMessage()->setBody($body, 'text/html'); + } + return $this; } From 0b70ed5c601d4d79a21b9655c2b54dc34973a9e1 Mon Sep 17 00:00:00 2001 From: cedric lombardot Date: Fri, 12 Jun 2020 17:12:28 +0200 Subject: [PATCH 2/2] Update Mailer.php --- Mailer/Mailer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Mailer/Mailer.php b/Mailer/Mailer.php index 9611a69..001cbd1 100644 --- a/Mailer/Mailer.php +++ b/Mailer/Mailer.php @@ -11,7 +11,10 @@ class Mailer private $message; private $options; - public function __construct(\Swift_Mailer $swift, \Twig_Environment $twig, $from, $replyTo, array $options) + /** + * $twig : Twig_Environment or \Twig\Environment + */ + public function __construct(\Swift_Mailer $swift, $twig, $from, $replyTo, array $options) { $this->swift = $swift; $this->twig = $twig;