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
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!
-
This worked for me Mayur. Thank you for the assistance.user112741– user1127412024年04月25日 21:10:19 +00:00Commented Apr 25, 2024 at 21:10
-
If it will help you, please upvote and accept as solution. So, it will help other in community.Mayur– Mayur2024年04月26日 04:23:19 +00:00Commented Apr 26, 2024 at 4:23