I have transactional template in send grid. In that email i have placeholders like: [first_name] etc...
I've tryied different options and ways to replace this placeholders.
What should i add to my code in order to make this work?
$from = new From("[email protected]", "Project");
$tos = [
new To(
'[email protected]', 'Example Name', ['first_name' => 'Example name'], 'Hello, test subject!'
)
];
$email = new Mail($from, $tos);
$email->setTemplateId('d-********************************');
$sendgrid = new \SendGrid(_SENDGRID_API_KEY_);
try {
$response = $sendgrid->send($email);
} catch (Exception $e) {
echo 'Caught exception: ' . $e->getMessage(). "\n";
}
I have also tried:
$substitutions = [
"first_name" => "Steve"
];
$email->addDynamicTemplateDatas($substitutions);
Doesn't work for me.
@thinkingserious thank you!!! Worked for me 馃憤
{{placeholder}} - this was the right placeholder.
Most helpful comment
Hello @solonifer,
Could you please try this example? Thanks!
With Best Regards,
Elmer