Embed Image in HTML String Email Laravel

286 Views Asked by At

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

0

There are 0 best solutions below