Issue Summary
I am trying to send an email through Sendgrid API v3 (using Sendgrid's PHP SDK v7.0) using a transactional template with substitutions. If I send the email without substitions then I get a HTTP 202 and the email is successfully sent. However, as soon aas I try to add a substitution, then I get a HTTP "400 Bad Request - Substitutions may not be used with dynamic templating". I have tried many different ways to get those substitions working, I have even used the examples provided in the documentation and I am still gettting the same error.
Steps to Reproduce
Please find below the PHP code used:
$sendgrid = new SendGrid('sendgrid.key');
$email = new \SendGrid\Mail\Mail();
$email->setSubject("Sendgrid test");
$email->addTo("test@example.com", "Test");
$email->addSubstitution("-content-", "content");
$email->setFrom("dev@example.com", "Dev");
$email->addContent(
"text/html",
"<strong>TEST</strong>"
);
$email->setTemplateId("template-id");
try {
$response = $this->driver->send($email);
print $response->statusCode() . "\n";
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
And the HTML Template:
<html>
<head>
<title></title>
</head>
<body>
-content-
</body>
</html>
I have tried all sorts of substitution tags such as -, {{ }}, %, etc. None of them work.
Technical details:
- sendgrid-php Version: master (latest commit: [commit number])
- PHP Version: 7.2
Issue Summary
I am trying to send an email through Sendgrid API v3 (using Sendgrid's PHP SDK v7.0) using a transactional template with substitutions. If I send the email without substitions then I get a HTTP 202 and the email is successfully sent. However, as soon aas I try to add a substitution, then I get a HTTP "400 Bad Request - Substitutions may not be used with dynamic templating". I have tried many different ways to get those substitions working, I have even used the examples provided in the documentation and I am still gettting the same error.
Steps to Reproduce
Please find below the PHP code used:
And the HTML Template:
I have tried all sorts of substitution tags such as -, {{ }}, %, etc. None of them work.
Technical details: