I'm getting my custom data from email function and also I'm getting the Product image URL to show it in mail now I tried many ways to show my image in email but its not working for me my custom email code is

    {{template config_path="design/email/header_template"}} 
 <p align="center"><b style="color: #009900">Name:</b> {{trans "%name" name=$name}}</p>
 <p align="center"><b style="color: #009900">Email:</b> {{trans "%email" email=$email}}</p>
 <p align="center"><b style="color: #009900">Phone Number:</b> {{trans "%pnumber" pnumber=$pnumber}}</p>
 <p align="center"><b style="color: #009900">Offer Amount:</b> {{trans "%offeramount" offeramount=$offeramount}}</p>
 <p align="center"><b style="color: #009900">Message:</b> {{trans "%message" message=$message}}</p>
 <p align="center"><b style="color: #009900">Product Name:</b> {{trans "%product_name" product_name=$product_name}}</p>
 <p align="center"><b style="color: #009900">Product Price:</b> {{trans "%product_price" product_price=$product_price}}</p>
 <p align="center"><b style="color: #009900">URL:</b> {{trans '%imgUrl' imgUrl=$imgUrl}}</p>
 <!-- <img src="">{{trans '%imgUrl' imgUrl=$imgUrl}}</img> -->
 <!-- <img src="{{trans '%imgUrl' imgUrl=$imgUrl}}"> -->
 <img src="{{view url='%imgUrl'}}" height="30" width="30" alt="{{trans 'Custom image'}}" />
{{template config_path="design/email/footer_template"}}

I get the code from net which is

     src="{{view url='images/email/youtube.jpg'}}"
     alt="Website Youtube"

but now my question is how can I set Dynamic URL in place of fixed URL e.g in place of this URL images/email/youtube.jpg I want to set my URL

  • From wherever your email is been triggered after any action in controller you might be passing some variables just pass your email url also in email vars and consume them. For reference you can open any default Magento email templates. Mar 20, 2019 at 16:01
  • Sir I also pass the url as well if you can see this code {{trans '%imgUrl' imgUrl=$imgUrl}} in above code that is URL which I firstly just print in <p> to check that URL is coming properly or not after that I tried this for <img> tag but at that place it is not working
    – Asad Khan
    Mar 20, 2019 at 16:06
  • Try src = "{{ imgUrl}}" Mar 20, 2019 at 16:11
  • Are you.trying from your local ? Make sure you don't have any issue in showing images in every email ? Mar 20, 2019 at 16:13
  • Sir Actually firstly when I get the URL of the product then firstly I check it in phtml file for testing that is it getting the img of the product or not.. then its shows me the img perfectly after that I send the URL in the mail
    – Asad Khan
    Mar 20, 2019 at 16:15


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.