You are here

function amazon_ses_get_identity_list in Amazon SES 7

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

Retrieve sender identities and their status.

2 calls to amazon_ses_get_identity_list()
amazon_ses_domain_dkim_enable_form in includes/amazon_ses.admin.inc
Form for Enablling DKIM for sender's Identity.
amazon_ses_identity_list_form in includes/amazon_ses.admin.inc
Display Verified Sender Identites to Admin.

File

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

Code

function amazon_ses_get_identity_list($identity_type = NULL) {
  $options = array();

  // If identity type is not specified, then fetch both email & domain,for
  // this we will not send parameter 'IdentityType' in http request.
  if ($identity_type != NULL) {
    $action_parameter['IdentityType'] = $identity_type;
  }
  $result = NULL;
  $action_parameter['MaxItems'] = 10;
  module_load_include('inc', 'amazon_ses', 'includes/amazon_ses.mail');
  $result = amazon_ses_send_request('ListIdentities', $action_parameter);

  // Display the response of calling of Amazon SES API.
  if ($result['status'] == AMAZON_SES_REQUEST_FALIURE) {
    $message = t('Request to <strong>ListIdentities</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 FALSE;
  }
  unset($action_parameter);
  if (isset($result['member'])) {
    $action_parameter['Identities'] = $result['member'];
    $result = amazon_ses_send_request('GetIdentityVerificationAttributes', $action_parameter);
    $options = $result['token'];

    // Display the response of calling of Amazon SES API.
    if ($result['status'] == AMAZON_SES_REQUEST_FALIURE) {
      $message = t('Request to <strong>GetIdentityVerificationAttributes</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 FALSE;
    }
  }

  // Form filter component.
  $form['amazon_list_identities_filter'] = array(
    '#type' => 'fieldset',
    '#title' => t('Identites belongs to'),
    '#collapsed' => FALSE,
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
  );
  $form['amazon_list_identities_filter']['select_indentity'] = array(
    '#type' => 'select',
    '#title' => '',
    '#options' => array(
      'EmailAddress' => t('Email Address'),
      'Domain' => t('Domain'),
    ),
    '#default_value' => array(
      $identity_type,
    ),
  );
  $form['amazon_list_identities_filter']['filter_identity_list'] = array(
    '#type' => 'submit',
    '#value' => t('Filter'),
    '#submit' => array(
      'amazon_ses_identity_list_filter',
    ),
  );

  // Form component when Identity type is Domain.
  if ($identity_type == 'Domain') {
    $header = array(
      'key' => t('Domain Name'),
      'VerificationStatus' => t('Status'),
      'DomainRecordSet' => t('Domain Verification Record Set'),
    );
    $form['amazon_list_identities_filter']['#description'] = t('To complete
      domain verification, you must add a <strong>TXT</strong> record with the
      displayed <strong>Name</strong> and <strong>Value</strong> to
      your domain\'s DNS settings.') . '<br/>' . t('<strong>Note: </strong>Some
      domain name providers use the term <strong>Host</strong> instead of
      <strong>Name</strong>. If your DNS provider does not allow underscores in
      record names, you can omit the underscore before amazonses in the TXT
      record name.') . '<br/>' . t("When verification is complete, the domain's\n      status in the Amazon SES console will change from <strong>Pending</strong>\n      to <strong>Verified</strong>, and you will receive an Amazon SES Domain\n      Verification SUCCESS confirmation email from Amazon Web Services. (Amazon\n      Web Services emails are sent to the email address you used when you signed\n      up for Amazon SES.) <a href='@learn_more'>Learn more about verifying\n      domain in Amazon SES.</a>", array(
      '@learn_more' => 'http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-domains.html',
    )) . '<br/>';
  }
  else {
    $header = array(
      'key' => t('Email Address'),
      'VerificationStatus' => t('Status'),
    );
    $form['amazon_list_identities_filter']['#description'] = '<li>' . t('In your
      email client, open the message from Amazon SES asking you to confirm that
      you are the owner of this email address.') . '</li><li>' . t('Click the
      link in the message.') . '</li><li>' . t('<strong>Note:</strong> The link in
      the verification message expires 24 hours after your original verification
      request.') . '</li><li>' . t('The status of the email address in the Amazon
      SES console will change from <strong>Pending</strong> to <strong>Success
      </strong>.') . '</li>' . t('<a href="@learn_more">Learn more about
      verifying Emails in Amazon SES.</a>', array(
      '@learn_more' => 'http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html',
    )) . '<br/></br>';
  }

  // Form Update component.
  $form['amazon_list_identities_update'] = array(
    '#type' => 'fieldset',
    '#title' => t('Verified Idenities'),
    '#collapsed' => FALSE,
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
  );
  $form['amazon_list_identities_update']['list_table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#empty' => t('No content available.'),
  );
  return $form;
}