Sample code for 30+ languages & platforms
Dart

Amazon SES: Check sender verification status

See more Amazon SES Examples

Check the email identity created in Request sender verification. This read-only SES Query API operation uses ses:GetIdentityVerificationAttributes. It can look up several email addresses or domains in one signed request. Pending means SES is waiting for confirmation. Success means SES verified the identity. An address can also inherit verification from its domain.

GetIdentityVerificationAttributes

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // Assumes Chilkat is unlocked. See Global Unlock Sample.

  // Use the same AWS Region for the identity, endpoint, and Signature Version 4.
  final region = 'us-west-2';
  final host = CkStringBuilder();
  host.append('email.');
  host.append(region);
  host.append('.amazonaws.com');

  final signer = CkAuthAws();
  // Supply the credentials from your application's credential provider.
  signer.accessKey = 'AWS_ACCESS_KEY_ID';
  signer.secretKey = 'AWS_SECRET_ACCESS_KEY';
  signer.region = region;
  signer.serviceName = 'ses';

  final connection = CkSocket();
  connection.requireSslCertVerify = true;
  try {
    connection.connect(host.getAsString(), 443, true, 10000);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final rest = CkRest();
  try {
    rest.useConnection(connection, false);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  try {
    rest.setAuthAws(signer);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // For temporary AWS credentials, supply the session token from the same provider.
  final sessionToken = '';
  if (sessionToken != '') {
    rest.addQueryParam('X-Amz-Security-Token', sessionToken);
  }

  // This read-only SES Query action accepts up to 100 addresses or domains.
  // Pass the original mailbox name. Chilkat encodes the plus sign when signing the query.
  rest.addQueryParam('Action', 'GetIdentityVerificationAttributes');
  rest.addQueryParam('Version', '2010-12-01');
  rest.addQueryParam('Identities.member.1', 'sender+reports@example.com');
  final String responseText;
  try {
    responseText = rest.fullRequestNoBody('GET', '/');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  if (rest.responseStatusCode != 200) {
    print('SES returned HTTP ${rest.responseStatusCode} $responseText');
    return;
  }

  final result = CkXml();
  try {
    result.loadXml(responseText);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // A map entry contains the identity as key and its verification attributes as value.
  if (result.numChildrenAt('GetIdentityVerificationAttributesResult|VerificationAttributes') < 1) {
    print('No verification entry returned for this address in this Region.');
    return;
  }

  final status = result.getChildContent('GetIdentityVerificationAttributesResult|VerificationAttributes|entry|value|VerificationStatus');
  print('Verification status: $status');
  if (status == 'Pending') {
    print('Open the AWS verification email and follow its link.');
  }
}