0

Hello I wanted to embed an Image in a Mail in Laravel. Sure when using a link to the public resource for my image, it does work but I dont know if it is better than embedding the Image directly into the Email itself.

I dont use Markdown nor Email Templates.

My common occurring function looks like:

Mail::send([], [], function ($msg) use ($user, $content, $mail) {
                    $msg->to($user->mail);
                    $msg->subject($mail->title);
                    $msg->setBody($this->generateHtmlEmail($content, $user), 'text/html');
                });

When using a base64 encoded string for my image as source, it doesnt get displayed in clients such as Gmail etc.

I know there is a function like: $message->embed(path) but I dont know, how to implement it in my function since I use a html string as the body content

2
  • On the view you can put: <img src="{{ $message->embedData($data, 'example-image.jpg') }}"> like the docs code Commented May 26, 2023 at 13:47
  • Well, I don't use a view, I am using html strings. I mentioned it in the question Commented May 26, 2023 at 17:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.