Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Fix deprecations for embedded images in symfony mailer #46488

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Illuminate/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Jubeki marked this conversation as resolved.
Show resolved Hide resolved
);

return "cid:{$file->as}";
}
Expand All @@ -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";
}
Expand All @@ -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";
}
Expand Down