Laravel: How to embed image in an email as a content and not as an attachment


I have searched for ways to embed an image in an email sent with Laravel. The method I have found which most people use is to embed the image as an attachment.

<img src="{{$message->embed(asset('assets/img/logo.png'))}}" style="padding:0px; margin:0px" />

Is there a way to embed an image without it being an attachment? I tried converting the image to base64 strings but that didn't even work.

Best Solution

Whether its a good thing or not...

You nearly have it. I suppose the problem is that the asset() function is generating a full url and Laravel need the path to the file. Official Doc

Try this:

<img src="{{ $message->embed('assets/img/logo.png') }}" style="padding:0px; margin:0px" />