From faf578c66191cf7edac6d6341b40bfade491808c Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 27 May 2024 17:30:07 -0500 Subject: [PATCH] Internal: Allow to attach file in mail from stream - refs BT#21648 --- src/CoreBundle/ServiceHelper/MailHelper.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CoreBundle/ServiceHelper/MailHelper.php b/src/CoreBundle/ServiceHelper/MailHelper.php index d55d744cc5..520c9c2c57 100644 --- a/src/CoreBundle/ServiceHelper/MailHelper.php +++ b/src/CoreBundle/ServiceHelper/MailHelper.php @@ -12,6 +12,7 @@ use Symfony\Component\Mailer\Exception\TransportExceptionInterface; use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Mime\Address; use Symfony\Component\Mime\BodyRendererInterface; +use Symfony\Component\Mime\Part\DataPart; final class MailHelper { @@ -77,6 +78,10 @@ final class MailHelper if (!empty($file_attach['path']) && !empty($file_attach['filename'])) { $templatedEmail->attachFromPath($file_attach['path'], $file_attach['filename']); } + + if (!empty($file_attach['stream']) && !empty($file_attach['filename'])) { + $templatedEmail->addPart(new DataPart($file_attach['stream'], $file_attach['filename'])); + } } }