I want to add controller path in Email template.I have create custom email template using programmatically.

This is my code :-

{{template config_path="design/email/header_template"}}
    <tr class="custom-gdpr">
        <p><strong>Hello {{var name}} , </strong></p>
        <p>You Are Confirom Delete Your Account in Our Store. </p>
        <p>If {{trans '<a href="Here I want to controller URL">Yes</a>'|row}} Or  {{trans '<a href="Here I want to controller URL">No</a>'|row}}</p>
        <strong>Thank you</strong>
{{template config_path="design/email/footer_template"}}

I want to Following link add in For Example:-


Please Advice me How to add Dynamic URL,



Try the following way:

use Magento\Framework\DataObject;

Now when you send transactional email, you need to pass values as DataObject Object. Ex.

'data' => new DataObject($post)

Where $post is an array.

Set the variable like:


Check the Magento_Contact module as an example. Specially the following class:

1. vendor/magento/module-contact/Controller/Index/Post.php

private function sendEmail($post)
        ['data' => new DataObject($post)]

2. vendor/magento/module-contact/Model/Mail.php

public function send($replyTo, array $variables)
    /** @see \Magento\Contact\Controller\Index\Post::validatedParams() */
    $replyToName = !empty($variables['data']['name']) ? $variables['data']['name'] : null;

    try {
        $transport = $this->transportBuilder
                    'area' => Area::AREA_FRONTEND,
                    'store' => $this->storeManager->getStore()->getId()
            ->setReplyTo($replyTo, $replyToName)

    } finally {

3. vendor/magento/module-contact/view/frontend/email/submitted_form.html

{{var data.email}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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