I am using endroid/qr-code https://github.com/endroid/qr-code
to generate QrCode.
Now I need to send this QR to my email too.
I have used following codes:
$result = Builder::create()
->writer(new PngWriter())
->writerOptions([])
->data("This ist test page.")
->encoding(new Encoding('UTF-8'))
->size(200)
->margin(10)
->roundBlockSizeMode(new RoundBlockSizeModeMargin())
->logoPath($webPath)
->labelText('SCAN')
->build();
return $result->getDataUri();
At my email twig page I have
<img src = {{ $return_from_result_getDataUri }} >
I am getting broken img from above line.
When I use {{ $return_from_result_getDataUri }}, this gives me data:image/png;base64.....
text displayed.
Can anybody help me here.
Thanks.
Support for Embedding images with Data URI in Emails is still not optimal and many email clients don't support it at all.
See this analysis from Campaign Monitor showing many clients not rendering the Data URI image.
I strongly suggest you to upload the QR code somewhere and then link it as a normal image.
If your services are hosted on AWS, you can use S3.
Otherwise you can use free services but I don't have any experience with them. This is the first result I found: https://apidocs.imgur.com/
PS: Just adding that you might be missing some double quotes as well in your code.
<img src="{{ $return_from_result_getDataUri }}" >