You are here

function amazon_ses_verify_email_identity_amazon in Amazon SES 7

Same name and namespace in other branches
  1. 7.2 amazon_ses.module \amazon_ses_verify_email_identity_amazon()

Validate, if send email is not verified by Amazon SES.

File

./amazon_ses.module, line 137
Module file for amazon_ses.

Code

function amazon_ses_verify_email_identity_amazon($element, &$form_state) {
  if (isset($element['#value'])) {
    $action_parameter['Identities'][] = $element['#value'];

    // Call the amazon Query API action GetIdentityVerificationAttributes.
    module_load_include('inc', 'amazon_ses', 'includes/amazon_ses.mail');
    $result = amazon_ses_send_request('GetIdentityVerificationAttributes', $action_parameter, '');

    // Display the result in table returned by Amazon SES.
    switch ($result['status']) {
      case AMAZON_SES_REQUEST_SUCCESS:
        if (isset($result['token']['row0']['VerificationStatus'])) {
          $id_status = $result['token']['row0']['VerificationStatus'];
          if ($id_status == 'Pending') {
            form_error($element, t('@email address is in pending state, yet not verified by Amazon SES. \\n so Please contact amazon SES or change the mail', array(
              '@email' => $element['#value'],
            )));
          }
        }
        else {
          form_error($element, t('Please send request for verifying @email  address to Amazon SES, Or change the mail', array(
            '@email' => $element['#value'],
          )));
        }
        break;
      case AMAZON_MAIL_SERVICE_REQUEST_EXCEPTION:
        form_error($element, t('Sending request to amazon is failed!, Please try again'));
        break;
    }
  }
}