You are here

private function AmazonSes::getIdentityDkimAttributes in Amazon SES 7.2

Call Query API action GetIdentityNotificationAttributes.

This action is throttled at one request per second.

1 call to AmazonSes::getIdentityDkimAttributes()
AmazonSes::performServiceAction in src/AmazonSes.php
Add required parameter & header to the Query according to Query action.

File

src/AmazonSes.php, line 102
Class for interacting with Amazon SES service.

Class

AmazonSes
Modify the drupal mail system to use Amazon SES.

Namespace

Drupal\amazon_ses

Code

private function getIdentityDkimAttributes($action_parameter) {
  $result['error'] = FALSE;
  try {
    $response = $this->sesClient
      ->getIdentityDkimAttributes([
      'Identities' => $action_parameter['Identities'],
    ]);
    if (!empty($response['DkimAttributes'])) {
      foreach ($response['DkimAttributes'] as $key => $value) {
        $result['Identity'] = check_plain($key);
        $result['DkimEnabled'] = check_plain($value['DkimEnabled']);
        $result['DkimVerificationStatus'] = check_plain($value['DkimVerificationStatus']);
        $dkim_tokens = $value['DkimTokens'];

        // Prepare dkimTokens.
        if (strpos($result['Identity'], '@') != FALSE) {
          $temp_arr = explode('@', $result['Identity']);
          $domain = $temp_arr[1];
        }
        else {
          $domain = $result['Identity'];
        }
        foreach ($dkim_tokens as $token) {
          $name = (string) $token . '._domainkey.' . $domain;
          $value = (string) $token . '.dkim.amazonses.com';
          $result['member'][$key]['name'] = check_plain($name);
          $result['member'][$key]['value'] = check_plain($value);
          $result['member'][$key]['type'] = 'CNAME';
        }
      }
    }
  } catch (\Aws\Ses\Exception\SesException $e) {
    $result['message'] = $e
      ->getAwsErrorType();
    $result['errorCode'] = $e
      ->getAwsErrorCode();
    $result['error'] = TRUE;
  }
  return $result;
}