private function handleSendMMS()
 {
     if (!isset($_REQUEST['address'])) {
         return;
     }
     try {
         $this->copyToSession(array('address', 'subject', 'attachment', 'chkGetOnlineStatus'));
         $addr = Util::convertAddresses($_REQUEST['address']);
         $addr = count($addr) == 1 ? $addr[0] : $addr;
         $subject = $_REQUEST['subject'];
         $attachment = $_REQUEST['attachment'];
         $attachArr = array();
         if (strcmp($attachment, '') != 0) {
             $attachArr = array('attachment/' . $attachment);
         }
         $notifyDeliveryStatus = isset($_REQUEST['chkGetOnlineStatus']);
         $srvc = new MMSService($this->apiFQDN, $this->getFileToken());
         $response = $srvc->sendMMS($addr, $attachArr, $subject, null, $notifyDeliveryStatus);
         if (!$notifyDeliveryStatus) {
             $_SESSION['id'] = $response->getMessageId();
         }
         $this->results[MMSController::RESULT_SEND_MMS] = $response;
     } catch (Exception $e) {
         $this->errors[MMSController::ERROR_SEND_MMS] = $e->getMessage();
     }
 }
require_once __DIR__ . '/../lib/Util/Util.php';
require_once __DIR__ . '/../lib/MMS/MMSService.php';
use Att\Api\Util\Util;
use Att\Api\MMS\MMSService;
$arr = null;
try {
    envinit();
    $mmsService = new MMSService(getFqdn(), getFileToken());
    $addr = Util::convertAddresses($_POST['address']);
    $addr = count($addr) == 1 ? $addr[0] : $addr;
    $subject = $_POST['sendMsgInput'];
    $attachment = $_POST['attachmentInput'];
    $notifyDeliveryStatus = isset($_POST['receiveStatus']);
    $allowedFiles = array('None', 'att.gif', 'coupon.jpg');
    if (!in_array($attachment, $allowedFiles, true)) {
        throw new Exception('Invalid attachment file specified');
    }
    if ($attachment === 'None') {
        $attachment = array();
    } else {
        $attachment = array(__DIR__ . '/../attachment/' . $attachment);
    }
    $response = $mmsService->sendMMS($addr, $attachment, $subject, null, $notifyDeliveryStatus);
    $resourceUrl = $response->getResourceUrl();
    $resourceUrl = $resourceUrl == null ? '-' : $resourceUrl;
    $arr = array('success' => true, 'tables' => array(array('headers' => array('MessageId', 'ResourceURL'), 'values' => array(array($response->getMessageId(), $resourceUrl)))));
} catch (Exception $e) {
    $arr = array('success' => false, 'text' => $e->getMessage());
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */