Is it possible to assign $msgArray
as a last element of the array which is used in curl
foreach( $attachmentsArray as $att )
{
$msgArray["attachment[$x]"] = curl_file_create( $att );
$x ++;
}
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'from' => 'Open <test@gmail.com>',
'to' => $email,
'subject' => $subject,
'html' => $msg
));
Yes. Just as a pump, does this work for you?
foreach( $attachmentsArray as $att )
{
$msgArray["attachment[$x]"] = curl_file_create( $att );
$x ++;
}
$arrayValues = array(
'from' => 'Open <test@gmail.com>',
'to' => $email,
'subject' => $subject,
'html' => $msg,
'attachments' => http_build_query($msgArray)
/** or an alternative form of collapsing an array into a
string value, such as json_encode($msgArray); **/
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $arrayValues);
reference (recommended)