You are here

function amazon_ses_verify_sender_id_form_submit in Amazon SES 7

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

Submit handler for amazon identity request form.

File

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

Code

function amazon_ses_verify_sender_id_form_submit($form, &$form_state) {

  // Send Request to amzon SES API.
  module_load_include('inc', 'amazon_ses', 'includes/amazon_ses.mail');
  if (isset($form_state['values']['identity_type'])) {
    $identity_type = $form_state['values']['identity_type'];
    $_SESSION['amazon_selected_identity'] = $identity_type;
    switch ($identity_type) {
      case 'EmailAddress':
        $action_parameter['EmailAddress'] = $form_state['values']['identity_email'];
        $result = amazon_ses_send_request('VerifyEmailIdentity', $action_parameter);
        break;
      case 'Domain':
        $action_parameter['Domain'] = $form_state['values']['identity_domain'];
        $result = amazon_ses_send_request('VerifyDomainIdentity', $action_parameter);
        break;
    }
  }

  // Display the response of calling of Amazon SES API.
  switch ($result['status']) {
    case AMAZON_SES_REQUEST_SUCCESS:
      if ($identity_type == 'EmailAddress') {
        $message = t('A verification mail with further instruction has been sent to
          @mail By Amazon SES', array(
          '@mail' => $form_state['values']['identity_email'],
        ));
        drupal_set_message($message, 'status');
        drupal_goto('admin/config/aws-settings/aws-ses-sender-id-list');
      }
      elseif ($identity_type == 'Domain') {
        $message = t('In order to complete verification of this domain, you must
          create a TXT record in the DNS settings for the domain, with the value
          shown in TXT column.<br/> When Amazon Web Services has confirmed that
          these values are present in the DNS settings for the domain, the Status
          for the domain will change to <strong>verified</strong>. This may take up
          to 72 hours <a href="@learn_more">Learn More</a>', array(
          '@learn_more' => 'http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-domains.html',
        ));
        drupal_set_message($message, 'status');
        drupal_goto('admin/config/aws-settings/aws-ses-sender-id-list');
      }
      break;
    case AMAZON_SES_REQUEST_FALIURE:
      $message = t('Request to <strong>@action</strong> action of Amazon SES API
       call has failed, please check your network connection or try after some
        time', array(
        '@action' => "Verify{$identity_type}Identity",
      ));
      drupal_set_message($message, 'error');
      break;
  }
}