Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
monoulou opened this issue Apr 26, 2023 · 0 comments
Open

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

monoulou opened this issue Apr 26, 2023 · 0 comments

Comments

@monoulou
Copy link

monoulou commented Apr 26, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant