I am trying to pass data into my email template, something like this: ['catalogue_url' => 'http://url.html']

I am struggling to access and output it in the email, I have tried the following:

Test 1: {{var $catalogue_url|raw}}

Test 2: {{var $catalogue_url}}

Test 3: {{var $catalogue_url}}

Test 4: {{var catalogue_url}}

Test 5: {{catalogue_url}}

My email sending code:

    $transport = $this->_transportBuilder
            'area' =>  $area,
            'store' => $this->storeManager->getStore()->getId(),
        ->setTemplateVars(['data' => $data])


I will try with $data.catalogue_url now.

What is wrong with this?

  • 1
    Why don't you give any feedback about the answer? Commented Nov 9, 2017 at 13:14
  • 1
    I took a break from Magento development as I moved to the US. Apologies, best of luck with all of your work. Commented Nov 22, 2017 at 9:07

1 Answer 1


Try this:

$templateOptions = [
             'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
             'store' => $this->storeManager->getStore()->getId()
            $templateVars = [
                        'store' => $this->storeManager->getStore(),
                        'admin_name' => 'Admin',
                        'subject'    => 'subject',
                        'catalogue_url'    => 'pass url here'
            $from = ['email' => '[email protected]', 'name' => 'from name'];
            $to= "[email protected]"
            $transport = $this->transportBuilder->setTemplateIdentifier('template name or id')

Use in email template {{var catalogue_url}} variable

  • 6
    I think your answer is wrong. I have managed to call it with {{var catalogue_url}}. Commented Nov 9, 2017 at 13:13
  • 1
    Be aware to no use spaces after {{ or before }}. Wrong {{ var catalogue_url }}. Right {{var catalogue_url}}
    – nikoskip
    Commented Aug 21, 2019 at 20:05

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.