-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[10.x] Fix deprecations for embedded images in symfony mailer #46488
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm in general 👍
@Jubeki have you tried out a few scenarios with Helo or something similar?
I used Mailhog with the following code example (and an image stored in // app\Mail\TestMail.php
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class TestMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*/
public function __construct()
{
//
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: 'Test Mail',
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'test',
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
} {{-- resources/views/test.blade.php --}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<p>TEST E-Mail</p>
<img src="{{ $message->embed(storage_path('app/profile.jpg')) }}" alt="" style="height: 100px; width: 100px;" />
<img src="{{ $message->embedData(file_get_contents(storage_path('app/profile.jpg')), 'profile2.jpg') }}" alt="" style="height: 100px; width: 100px;" />
</body>
</html> |
perhaps best indeed that we try it out with ses as well. Also maybe try a data attachment? |
I updated the above example to also test the embedData method. Both work with Mailhog and SES. |
Thanks |
Fixes #46462
It seems like Symfony has deprecated the old way of embedding images in Mails since 6.2:
https://symfony.com/doc/current/mailer.html#embedding-images
This PR implements the new way of embedding images.