You are here

private function AmazonSesClass::getSendStatistics in Amazon SES 7

Call Query API action GetSendStatistics.

The result is a list of data points, representing the last two weeks of sending activity. Each data point in the list contains statistics for a 15 minute interval. This action is throttled at one request per second.

1 call to AmazonSesClass::getSendStatistics()
AmazonSesClass::performServiceAction in includes/classes/amazonses.class.php
Add required parameter & header to the Query according to Query action.

File

includes/classes/amazonses.class.php, line 187
Class for interacting with Amazon SES service.

Class

AmazonSesClass
Modify the drupal mail system to use Amazon SES.

Code

private function getSendStatistics($action_parameter) {
  $response_xml = $this->sesClient
    ->get_send_statistics($action_parameter);

  // Parse the xml response.
  $response = $response_xml->body
    ->to_stdClass();
  if ($response_xml->status == '200') {
    $result['status'] = AMAZON_SES_REQUEST_SUCCESS;

    // Number of emails that have been enqueued for sending.
    $result['DeliveryAttempts'] = 0;

    // Number of emails rejected by Amazon SES.
    $result['Rejects'] = 0;

    // Number of emails that have bounced.
    $result['Bounces'] = 0;

    // Number of unwanted emails that were rejected by recipients.
    $result['Complaints'] = 0;
    if (isset($response->GetSendStatisticsResult->SendDataPoints->member)) {
      $member = $response->GetSendStatisticsResult->SendDataPoints->member;
      if (is_array($member)) {
        foreach ($member as $value) {
          $result['DeliveryAttempts'] = check_plain($value->DeliveryAttempts) + $result['DeliveryAttempts'];
          $result['Rejects'] = check_plain($value->Rejects) + $result['Rejects'];
          $result['Bounces'] = check_plain($value->Bounces) + $result['Bounces'];
          $result['Complaints'] = check_plain($value->Complaints) + $result['Complaints'];
        }
      }
      else {
        $result['DeliveryAttempts'] = check_plain($member->DeliveryAttempts);
        $result['Rejects'] = check_plain($member->Rejects);
        $result['Bounces'] = check_plain($member->Bounces);
        $result['Complaints'] = check_plain($member->Complaints);
      }
    }
  }
  else {
    $result['status'] = AMAZON_SES_REQUEST_FALIURE;
  }
  return $result;
}