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()}}

asked Apr 24, 2024 at 16:13

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!

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.