<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Enter your Access Key ID
$AWSAccessKeyId = 'AKIATDZTTWFOORJK72OW';

// Enter your Secret Access Key
$AWSSecretKey = 'CsSMVLcMgp/qz3WF2OXUmaFbogbqIlSB/WLklQIx';

// Enter your Region
$AWSRegion = 'us-east-1';

require 'aws-sdk/aws-autoloader.php';

use Aws\Ses\SesClient;

/* Reference to the ses client */
$client = SesClient::factory(array(
    'version' => 'latest',
    'region'  => $AWSRegion,
    'credentials' => array(
      'key' => $AWSAccessKeyId,
      'secret'  => $AWSSecretKey,
    )
  ));

 
//Now that you have the client ready, you can build the message
$msg = array();
$msg['Source'] = "indeval@grupobmv.com.mx";
//ToAddresses must be an array
$msg['Destination'] = array(
   'ToAddresses' => array('armando@wearetrafika.com')
   //'CcAddresses' => array('someone@example.com' ),
   //'BccAddresses' => array('someone@example.com')
);

//Next we will form the body of the email:

$msg['Message'] = array(
     // Subject is required
     'Subject' => array(
       // Data is required
      'Data' => 'Test Msg',
      'Charset' => 'UTF-8',
   ),
   // Body
  'Body' => array(
    'Text' => array(
     // Data
     'Data' => 'This is a test msg',
     'Charset' => 'UTF-8',
     ),
    'Html' => array(
     // Data is required
     'Data' => 'Dear Customer, 
                This is a test message. 
                Regards
                ',
     'Charset' => 'UTF-8',
    ),
  )
);

//Now you are all set. You call sendEmail to send the email:

try{
$result = $client->sendEmail($msg);

//Msg id from AWS. Can be used for tracking.
$msg_id = $result->get('MessageId');
echo("MessageId: $msg_id");

//view sample output
print_r($result);
} catch (Exception $e) {
//Exception Caught.
echo($e->getMessage());
}

//Print the result to check if it is successful
print_r($result);
