I use following code to send an e-mail from a custom page in case a creditcard transaction fails. With this example I try to send the e-mail to the client with client id 1.
The response result gives a success, but no e-mail is being send. Can anyone point me to what I'm doing wrong here?
<?php
include("dbconnect.php");
include("includes/functions.php");
include("includes/clientfunctions.php");
$username = "admin";
$password = "xxxxxx";
$url = "http://www.xxxxx.xxx/clients/includes/api.php"; # URL to WHMCS API file
$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["action"] = "sendemail";
$postfields["messagename"] = "Credit Card Payment Failed";
$postfields["id"] = "1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
curl_close($ch);
?>