Skip to content

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

Description

@monoulou

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions