Hi,
I’m having trouble with variables not rendering in the emails sent via Brevo.
Here’s the relevant part of the PHP request:
$data = [
'sender' => [
'name' => self::RECIPIENT_NAME,
'email' => self::RECIPIENT_EMAIL
],
'to' => [[
'email' => self::RECIPIENT_EMAIL,
'name' => self::RECIPIENT_NAME
]],
'subject' => "New contact form request: " . $subject,
'templateId' => $templateId,
'params' => [
'name' => $name,
'email' => $email,
'subject' => $subject,
'question' => $question
]
];
$client = new Client();
try {
$response = $client->request('POST', 'https://api.brevo.com/v3/smtp/email', [
'headers' => [
'api-key' => $apiKey,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'json' => $data,
]);
I’ve confirmed that the name, email, subject, and question variables are populated correctly in PHP.
Here’s what the received emails look like:
The HTML in the Brevo editor looks like this:
<p style="margin: 0;">Name: <span title="{{ name }}" contenteditable="false" data-placeholder="name" class="placeholder rte-personalized-node fr-deletable">name</span></p>
<p style="margin: 0;">Email: <span title="{{ email }}" contenteditable="false" data-placeholder="email" class="placeholder rte-personalized-node fr-deletable">email</span></p>
<p style="margin: 0;">Subject: <span title="{{ subject }}" contenteditable="false" data-placeholder="subject" class="placeholder rte-personalized-node fr-deletable">subject</span></p>
<p style="margin: 0;">Question: <span title="{{ question }}" contenteditable="false" data-placeholder="question" class="placeholder rte-personalized-node fr-deletable">question</span></p>
</td>
From other examples I’ve seen, passing the variables through the params array like this should be enough:
'params' => [
'name' => $name,
'email' => $email,
'subject' => $subject,
'question' => $question
]
Yet the values aren’t rendering in the email—only the placeholder labels show up.
Do you have any idea what might be going wrong?
Thanks in advance!