APIv3-php-library
APIv3-php-library copied to clipboard
Error "message":"to is not valid in messageVersions"
I'm struggling to make batch send customised HTML Emails... here is the code ` $config = new Configuration(); $config->setApiKey("api-key", $company->getMailerApiKey()->getApiKey());
$apiInstance = new TransactionalEmailsApi(null, $config);
$content["sender"] = ['name' => $company->getName(), 'email' => $company->getEmail()];
$messagesVersions = [];
$message = [];
foreach ($body as $data) {
$message["to"] = [$data["email"]];
$message["subject"] = $data["object"];
$message["htmlContent"] = $data["html"];
$messagesVersions[] = $message;
}
$content["messageVersions"] = $messagesVersions;
$sendSmtpEmail = new SendSmtpEmail($content);
try{
$response = $apiInstance->sendTransacEmail($sendSmtpEmail);
dd($response);
} catch (Exception $e) {
echo $e;
return false;
}`
For each recipients I would like to send a customised subject and htmlContent and i don't know why I get this error message : "code":"invalid_parameter","message":"to is not valid in messageVersions"...Even if messageVersions documentation is showing to use "to" parameter to define destination.
Please, Can anyone help me ??? Thks!!