How to bind product image to email in Magento2.2.5?

I have created custom module in which I need to bind product image to email template in Magento2.2.5?

My code:

$requestData["imgUrl"] = $data["shareProdImg"];


            $postObject = new \Magento\Framework\DataObject();
            $postObject->setData($requestData);

            $transport = $this->transportBuilder
                ->setTemplateIdentifier('custom_pdp_email_template')
                ->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])
                ->setTemplateVars(['data' => $postObject])
                ->setFrom(['name' => $data["userName"],'email' => $data["userMail"]])
                ->addTo($data["shareMail"])
                ->getTransport();
            $transport->sendMessage(); 

My template file:

<li style="font-weight:300;color:black !important;font-family: lato;font-size:16px;margin-left:0;">
                    {{depend data.imgUrl}}
                    {{trans "%imgUrl" imgUrl=$data.imgUrl}}<br/>
                    {{/depend}}
                </li>

                <li style="font-weight:300;color:black !important;font-family: lato;font-size:16px;margin-left:0;">
                     <img alt="" data-bind="attr: { src: getImagepaypal() }" alt="Custom image" width="60" height="60">
                </li>

Any help would be appreciated.

Solutions

You have to punch to $data["shareProdImg"] add to $postObject.

$postObject['imgUrl'] = $data["shareProdImg"];

Similar questions

Bind subdomain to a Magento Controller
I am working on an application for which I want to create few sub-domains in system, which will be served by Magento application. One example scenario can be creating separate sub-domains for system user's profile. Where User A will have dedicated url user-a.example.com and user B will have a url user-b.example.com. Now, I want to able to map these...
How to bind an action after customer login success using Magento?
I'm using Magento 1.4.1.1. After logout success, customer is rooted to "logout.phtml" first and "home page" later. Is there anyway I could make Magento run couple of "php" codes after "login" success ? Please don't hesitate to provide code samples as I'm new in Magento. /var/www/app/etc/modules/Lpf_ModuleCookie.xml /var/www/app/code/local/Lpf/Modul...
How to run direct SQL query on magento and bind WHERE IN params?
I have an array like this: For these skus, I need to know their product ID's, so ran the following script to run a direct sql query on magento core_read connection with parameter binding like this: When the script executes, it looks like this (not what I was expecting): All I am trying to do is get a list of entity_id, sku for an array of sku list ...
How to add a custom data-bind function to a minicart item in Magento 2
I'm trying to add some functionality to the minicart product items. On product list and view I was able to add this throught requirejs/knockout. Now, I can't find how to work with the minicart item. How can I add functions to the uiComponent for a minicart product item?
Magento 2 Knockout JS How to bind data from response of ajax call
I want to bind image source to following div. Following is my ajax call and their is my variable which I want to bind to image src. Also I am unable to access bankImage variable inside Ajax call. Please tell me how to access that variable in ajax function.
Magento 2 knockoutjs error data-bind even?
I have created custom template with knockoutjs in magento 2.1.7. The file name mytemplate.phtml This is the content of file Namespace_Module/web/js/template/listing.html This is the content of file Namespace_Module/web/js/view/listing.js when i load get error message is Unable to process binding "click: function (){return myFunction }" pls let me k...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.