APIv3-php-library icon indicating copy to clipboard operation
APIv3-php-library copied to clipboard

Error "message":"to is not valid in messageVersions"

Open monoulou opened this issue 1 year ago • 0 comments

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!!

monoulou avatar Apr 26 '23 14:04 monoulou