You are here

function amazon_ses_get_mail_statistics_form in Amazon SES 7

Same name and namespace in other branches
  1. 7.2 includes/amazon_ses.admin.inc \amazon_ses_get_mail_statistics_form()

Display Sending Quota and Statistics data.

@todo Sendign Quota and statistics should be displayed to user in better GUI and user of graph.

1 string reference to 'amazon_ses_get_mail_statistics_form'
amazon_ses_menu in ./amazon_ses.module
Implements hook_menu().

File

includes/amazon_ses.admin.inc, line 393
Administration menu callbacks for amazon_mail_service.

Code

function amazon_ses_get_mail_statistics_form($form, $form_state) {
  module_load_include('inc', 'amazon_ses', 'includes/amazon_ses.mail');
  $result_quota = amazon_ses_send_request('GetSendQuota', array());
  if ($result_quota['status'] == AMAZON_SES_REQUEST_FALIURE) {
    $message = t('Request to <strong>GetSendQuota</strong> action of Amazon SES
      API call has failed, please check your network connection or try after some time.');
    drupal_set_message($message, 'error');
    return '';
  }
  $form['sending_limits_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Your Amazon SES Sending Limits'),
    '#collapsed' => FALSE,
  );
  $form['sending_limits_fieldset']['sending_limit_data'] = array(
    '#prefix' => t('<strong>Sending Quota:</strong> Send @max_send emails per 24
    hour period.', array(
      '@max_send' => $result_quota['Max24HourSend'],
    )) . '<br/>' . t('<strong>Sent Mail:</strong> @sent_last', array(
      '@sent_last' => $result_quota['SentLast24Hours'],
    )) . '<br/>' . t('<strong>Max Send Rate:</strong> @send_rate Email/second.', array(
      '@send_rate' => $result_quota['MaxSendRate'],
    )),
  );
  $result_statistics = amazon_ses_send_request('GetSendStatistics', array());
  if ($result_statistics['status'] == AMAZON_SES_REQUEST_FALIURE) {
    $message = t('Request to <strong>GetSendStatistics</strong> action of Amazon
      SES API call has failed, please check your network connection or try after some time.');
    drupal_set_message($message, 'error');
    return '';
  }
  $form['sending_statistics_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Your Amazon SES Metrics'),
    '#collapsed' => FALSE,
  );
  $form['sending_statistics_fieldset']['sending_statistics_data'] = array(
    '#prefix' => t('<strong>Total number of mails sent:</strong> @delivery_attempts
    in last two weeks.', array(
      '@delivery_attempts' => $result_statistics['DeliveryAttempts'],
    )) . '<br/>' . t('<strong>Total number of Bounces Mail:</strong> @bounces in
    last two weeks.', array(
      '@bounces' => $result_statistics['Bounces'],
    )) . '<br/>' . t('<strong>Total number of Complaints mail:</strong> @complaints
    in last two weeks.', array(
      '@complaints' => $result_statistics['Complaints'],
    )) . '<br/>' . t('<strong>Total number of Rejected mail:</strong> @rejects in last two
    weeks.', array(
      '@rejects' => $result_statistics['Rejects'],
    )) . '<br/>',
  );
  return $form;
}