'How to Send an Email Template to multiple Recipients in Laravel

I am working with Sendinblue API. I am trying to send an email to multiple recipients using sendinblue api. I don't not know how, I can implement it in laravel. I tried it by using multiple inputs but getting error.

I have tried the below code with multiple inputs but getting "Array to string conversion"

If you know the solution please leave your response it will be highly appreciated. Thank you.

    $ch = curl_init();
    $count = count($request->name);

    curl_setopt($ch, CURLOPT_URL, 'https://api.sendinblue.com/v3/smtp/email');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    for ($i=0; $i < $count; $i++)
    {
        curl_setopt($ch, CURLOPT_POSTFIELDS,

            "\n{\n\"sender\": {\n\"name\": \"$request->name[$i]\",
        \n\"email\": \"$request->email[$i]\"\n},
        \n\"to\":[\n{\n\"email\": \"$request->recieverEmail[$i]\",
        \n\"name\": \"$request->recieverName[$i]\"\n},
        \n\"replyTo\": {\n\"email\": \"$request->replyEmail[$i]\",
        \n\"name\": \"$request->replyName[$i]\"\n},
        \n\"tags\": [\n\"$request->tag[$i]\"\n],
        \n\"templateId\": $request->id[$i]\n}\n"
        );
    }
    curl_setopt($ch, CURLOPT_POST, 1);
    $headers = array();
    $headers[] = 'Accept: application/json';
    $headers[] = 'Content-Type: application/json';
    $headers[] = 'Api-Key: API KEY';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    }
    curl_close($ch);
    $result = json_decode($result);
    dd($result);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source