如何使用infobip服务发送电子邮件

I am now developing a web application and it needs to send emails. I first used smtp service and for some reason I have chosen infobip.com for emailing service. It has good documentations on api so I followed the tutorial. The problem is even though I think I followed all steps I have some error like "bad request"

There is api for sending sms using infobip service. (https://github.com/pnlinh) But no api for sending emails.

private $from = "some person";
private $subject = "test subject";

private function setPostData($to, $text)
{
return [
'from' => $this->from,
'to'   => (array) $to,
'subject' => $this->subject,
'text' => $text,
];
}
public function testFunction()
{
$header = ['Content-Type:application/json', 'Accept:application/json'];
$postUrl = 'https://api.infobip.com/email/1/send';
$to = 'scar20181228@gmail.com';
$text = 'test email';
$postDataJson = json_encode($this->setPostData($to, $this->subject, $text));

// Set retry time if response is null or empty
$retrytime = 0;
retry_from_here:

$ch = curl_init();
// Setting options
curl_setopt($ch, CURLOPT_URL, $postUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'username'.':'.'password');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postDataJson);

// Response of the POST request
$response = curl_exec($ch);

if ($response === '' && $retrytime <= static::RETRY_TIME) {
$retrytime++;
goto retry_from_here;
}

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseBody = json_decode($response);
curl_close($ch);

return [$httpCode, $responseBody];