<?php

// MessageAPI.php file must be in the required path
// Note: Make sure to change the Account ID and API Key in the MessageAPIConfig.php file
require_once 'MessageAPI.php';
$params = array("toEmail" => '*****@*****.**', "toName" => 'EmailUser', "subject" => 'Single Message Sample', "body" => 'This message is only a test sent by the PHP MessageBus client library.', "fromName" => 'API', "fromEmail" => '*****@*****.**', "tag" => 'PHP', "plainText" => '1');
if (!SingleMessageAPI::send($params)) {
    echo "Error sending message: " . SingleMessageAPI::getLastError();
} else {
    echo "Message sent successfully!\n";
}
 /**
  * Send message
  * @param array $params
  * @param string $url (optional)
  * @return boolean
  */
 public static function send(array $params, $url = MESSAGE_API_URL)
 {
     $msg = new MessageAPI();
     if ($url != MESSAGE_API_URL) {
         $msg->setURL($url);
     }
     $rc = $msg->send($params);
     SingleMessageAPI::$errorMessage = $msg->getLastError();
     $msg->close();
     return $rc;
 }