Transactional Mails with API issues

Raydar

Member
I tried using api to send transactional mails with this php code

PHP:
<?php

$data = [ 
'to_name'           => 'John Doe', // required
'to_email'          => 'remzino1@gmail.com', // required
'from_name'         => 'Jane Doe', // required
'subject'           => 'This is the email subject', // required
'body'              => '<strong>Hello world!</strong>', // required
'send_at'           => date('Y-m-d H:i:s'), 
];

$url = 'https://[mailwizz-api-url]/api/transactional-emails';
$apiKey = 'api-key';

$curl = curl_init(); 
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_HTTPHEADER => array(
'X-Api-Key: ' . $apiKey,
'Content-Type: application/x-www-form-urlencoded'
 ),
)); 
$response = curl_exec($curl); 
curl_close($curl);

echo $response;

?>

but i got the error response
Code:
{"status":"error","error":"To email cannot be blank.<br \/>To name cannot be blank.<br \/>From name cannot be blank.<br \/>Subject cannot be blank.<br \/>Body cannot be blank."}

I tried using postman too, still the same thing.
What do i need to do?
This is urgent please.
 
Alright, Thanks for this.
Do you have the client available for other languages like python, nodejs et all.
It will be highly needed.
 
If i may plug this in here,
Any reason why my site might suddenly stop receiving webhook requests?
i have checked with the hosting and they claim it isn't from them that i should check with my developer.
 
403 means forbidden, so maybe something changed on your server. if it used to work and now it does not, that's where you need to look.
Check the regular subscription form, add a dummy example, see if that works.
 
Back
Top