Jack Daniels
Jack Daniels

Reputation: 43

How do i add Mailgun variables into a template?

I've just started using mailgun, and i've created a template on their dashboard.

In my codeigniter project i've added the following code :

$this->mailgun::send([
  'from' => "ZooTopia <[email protected]>",
  'to' => "[email protected]",
  'subject' => "Welcome to BB.com",
  'text' => "We just want to say hi. Have fun at Example.com",
    'template' => "test",
    'v:name' => "Jamie"
]);

I want to be able to display the variable for name onto the transactional email template i've created on the mailgun site.

I tried %name% but that doesn't seem to work.

any ideas?

Upvotes: 1

Views: 867

Answers (1)

damianz
damianz

Reputation: 21

What is your template code?

try to use {{name}} instead of %name%

Mailgun is using https://handlebarsjs.com/ for templates

also try to replace

'v:name' => "Jamie"

to:

'h:X-Mailgun-Variables' => '{"name": "Jamie"}'

Upvotes: 2

Related Questions