0

I am including a variable email in my template. But it does not format to be clicked and open in the recipients email app (specifically gmail). I have figured out how to do this with a hardcoded email, but not a variable formatted email. Looking for assistance in how to code.

{{var order.getCustomerEmail()}}

1 Answer 1

0

To ensure that the email address variable in your Magento 2 template is formatted as a clickable link that opens in the recipient's email app (such as Gmail), you can use HTML anchor tag syntax along with the mailto: prefix. Here's how you can modify your template:

<a href="mailto:{{var order.getCustomerEmail()}}">{{var order.getCustomerEmail()}}</a>

This code will generate a clickable email link where the email address is populated dynamically from the order.getCustomerEmail() variable. When the recipient clicks on the link, it should open their default email client (such as Gmail) with a new email draft pre-filled with the recipient's email address.

Make sure to test it to ensure it works as expected!

2
  • This worked for me Mayur. Thank you for the assistance.
    – user112741
    Commented Apr 25 at 21:10
  • If it will help you, please upvote and accept as solution. So, it will help other in community.
    – Mayur
    Commented Apr 26 at 4:23

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.