Looking for a good PHP/Curl Example for Transactional Emails

Hello I am looking for a good example of a PHP/Curl to integrate with these Transactional Emails.  This does not work but something like this. Does anyone have this?


$user_id = "123";
$user_name = "Billy Boy";
$user_email = "test@gmail.com";

$login = '4487dccccccccccccccccccccccccccccc'; // client ID
$password = '292ccccccccccccccccccccccccccccccccc'; // APi key
$url = 'https://api.createsend.com/api/v3.1/transactional/smartemail/135f6a51-xxxxxxxxxxxxxxxxxxxxxxx/send';

$data = array(
  "To" => ["Test<test@gmail.com>"],
  "Data" => array (
    "trader_id" => " . $user_id . ",
    "trader_name" => " . $user_name . ",
    "trader_email" => " . $user_email . "     

$data_string = json_encode($data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                         
    'Content-Type: application/json',                                                                               
    'Content-Length: ' . strlen($data_string))                                                                       
$result = curl_exec($ch);


Mercer, 1 year ago

Hi there 83email83,

Great question! I responded to your email as well, but thought that a public response here might also be helpful for anyone else looking. You can find samples of all of our Transactional API methods for our PHP wrapper here: https://github.com/campaignmonitor/createsend-php/tree/b1561d5fc1a65b4a677d99e6b4a651633449d6a1/samples/transactional.

I hope this helps, but please do let me know if you have any questions at all.

Join 150,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free