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.
Email providers, like Gmail, allow you to drag an image from a folder and drop it into an area inside the compose box that says “attach files here”. Gmail will automatically embed the image and realign it so it's in line with the rest of the plain text.
Embedding an image into an email message is the act of adding the image into the coding of the email template for it to appear amongst the text once the subscriber opens it, instead of appearing as an email attachment.
In a nutshell, embedding an image means adding it into the text of the email message. Hence, making it appear exactly as it is on a website rather than as an attachment.
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With