function sendEmail($params)
{
    global $MessageObject;
    if (!$MessageObject) {
        $MessageObject = new MessageAPI();
    }
    $MessageObject->send($params);
}
<?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';
$toEmails = array('*****@*****.**', '*****@*****.**');
$msg = new MessageAPI();
foreach ($toEmails as $toEmail) {
    $params = array("toEmail" => $toEmail, "toName" => '', "subject" => 'Multiple Message Sample', "body" => 'This message is only a test sent by the PHP MessageBus client library.', "fromName" => 'API', "fromEmail" => '*****@*****.**', "tag" => 'PHP', "plainText" => '1');
    if (!$msg->send($params)) {
        echo "Error sending message to {$toEmail} : " . $msg->getLastError();
    } else {
        echo "Message sent successfully to {$toEmail} \n";
    }
}
$msg->close();
예제 #3
0
 /**
  * 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;
 }