From 12c5b0fc785c5a4f20edacbac97b1d756f961434 Mon Sep 17 00:00:00 2001 From: Julius Kiekbusch Date: Thu, 16 Mar 2023 14:32:53 +0100 Subject: [PATCH] Fix deprecations for embedded images in symfony mailer --- src/Illuminate/Mail/Message.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Mail/Message.php b/src/Illuminate/Mail/Message.php index a0420b5af748..170b6bcd636e 100755 --- a/src/Illuminate/Mail/Message.php +++ b/src/Illuminate/Mail/Message.php @@ -7,6 +7,8 @@ use Illuminate\Support\Traits\ForwardsCalls; use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Email; +use Symfony\Component\Mime\Part\DataPart; +use Symfony\Component\Mime\Part\File; /** * @mixin \Symfony\Component\Mime\Email @@ -344,12 +346,16 @@ public function embed($file) function ($path) use ($file) { $cid = $file->as ?? Str::random(); - $this->message->embedFromPath($path, $cid, $file->mime); + $this->message->addPart( + (new DataPart(new File($path), $cid, $file->mime))->asInline() + ); return "cid:{$cid}"; }, function ($data) use ($file) { - $this->message->embed($data(), $file->as, $file->mime); + $this->message->addPart( + (new DataPart($data(), $file->as, $file->mime))->asInline() + ); return "cid:{$file->as}"; } @@ -358,7 +364,9 @@ function ($data) use ($file) { $cid = Str::random(10); - $this->message->embedFromPath($file, $cid); + $this->message->addPart( + (new DataPart(new File($file), $cid))->asInline() + ); return "cid:$cid"; } @@ -373,7 +381,9 @@ function ($data) use ($file) { */ public function embedData($data, $name, $contentType = null) { - $this->message->embed($data, $name, $contentType); + $this->message->addPart( + (new DataPart($data, $name, $contentType))->asInline() + ); return "cid:$name"; }