1

The problem

I am trying to send a QR image through a markdown mail. This image is in a controller and then passed to the mail format. Then inside I try to display the image with:

<img src="{{ $qr_image }}" alt="QR" title="QR" style="display:block; margin-left: auto; margin-right: auto;" width="200" height="200" data-auto-embed="attachment"/>

I am using the eduardokum/laravel-mail-auto-embed package. Now comes the odd part. When sending a mail to an outlook test account, the QR image shows without any problem at all. However when sending to a gmail account I get the following: enter image description here. I have tried data-auto-embed="base64" but that didn't solve the provlem.

Is maybe there a way to reference to $qr_image with a file path, since google doesn't like base64?

Mart Hagedoorn
  • 80
  • 1
  • 3
  • 9
  • Possible duplicate of [Gmail blocking small embedded inline images in email template](https://stackoverflow.com/questions/41946783/gmail-blocking-small-embedded-inline-images-in-email-template) – cherrysoft Aug 29 '18 at 09:03
  • Possible duplicate of [laravel 5.4 embed image in mail](https://stackoverflow.com/questions/42503168/laravel-5-4-embed-image-in-mail) – Gufran Hasan Aug 29 '18 at 09:04
  • did you get the correct image link?? – Sohel0415 Aug 29 '18 at 09:06
  • Those solutions don't work for me. And they use the file path while I use a variable, don't know if that makes a difference. And I guess it is the correct link since it does work in outlook. – Mart Hagedoorn Aug 29 '18 at 09:08

2 Answers2

1

Firstly, make sure that the image is within the public directory. This could be somewhere like public/img/emails/image.jpg.

You will now be able to use the asset() helper which creates an absolute link to the file within the public directory. So the following should work:

<img src="{{ asset('img/emails/' . $qr_image }}" alt="QR" title="QR" style="display:block; margin-left: auto; margin-right: auto;" width="200" height="200" data-auto-embed="attachment"/>

Assuming the $qr_image is just the name and extension of the file.

Saurabh Mistry
  • 12,833
  • 5
  • 50
  • 71
thisiskelvin
  • 4,136
  • 1
  • 10
  • 17
0

Try this:

 <img src="<?php echo $message->embed($pathToImage); ?>" style="max-width: 80%;padding-top: 20px;">

and in your controller something like this

'pathToImage' => public_path()."/images/1stgroup.jpeg"
Mokariya Sanjay
  • 194
  • 3
  • 13