Sample code for 30+ languages & platforms
Objective-C

Amazon SES v2: Request verification of a sender email address

See more Amazon SES Examples

Create an email identity in the AWS Region where the application sends mail. Use a mailbox you control and credentials with ses:CreateEmailIdentity. SES emails a verification link that expires after 24 hours. After following it, run Check sender verification status in the same Region.

CreateEmailIdentity · Verify an email identity

Chilkat Objective-C Downloads

Objective-C
#import <CkoJsonObject.h>
#import <NSString.h>
#import <CkoStringBuilder.h>
#import <CkoAuthAws.h>
#import <CkoSocket.h>
#import <CkoRest.h>

BOOL success = NO;

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

success = NO;

//  Use an address whose inbox you can open. SES sends the verification link there.
CkoJsonObject *request = [[CkoJsonObject alloc] init];
[request UpdateString: @"EmailIdentity" value: @"sender+reports@example.com"];

//  Use the same AWS Region for the identity, endpoint, and Signature Version 4.
NSString *region = @"us-west-2";
CkoStringBuilder *host = [[CkoStringBuilder alloc] init];
[host Append: @"email."];
[host Append: region];
[host Append: @".amazonaws.com"];

CkoAuthAws *signer = [[CkoAuthAws alloc] init];
//  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";

CkoSocket *connection = [[CkoSocket alloc] init];
connection.RequireSslCertVerify = YES;
success = [connection Connect: [host GetAsString] port: [NSNumber numberWithInt: 443] ssl: YES maxWaitMs: [NSNumber numberWithInt: 10000]];
if (success != YES) {
    NSLog(@"%@",connection.LastErrorText);
    return;
}

CkoRest *rest = [[CkoRest alloc] init];
success = [rest UseConnection: connection autoReconnect: NO];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

success = [rest SetAuthAws: signer];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

//  For temporary AWS credentials, supply the session token from the same provider.
NSString *sessionToken = @"";
if (sessionToken != @"") {
    [rest AddQueryParam: @"X-Amz-Security-Token" value: sessionToken];
}

[rest AddHeader: @"Content-Type" value: @"application/json"];
NSString *responseText = [rest FullRequestString: @"POST" uriPath: @"/v2/email/identities" bodyText: [request Emit]];
if (rest.LastMethodSuccess != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

if ([rest.ResponseStatusCode intValue] == 409) {
    NSLog(@"%@",@"This identity already exists in this Region. Check its verification status.");
    return;
}

if ([rest.ResponseStatusCode intValue] != 200) {
    NSLog(@"%@%d%@%@",@"SES returned HTTP ",[rest.ResponseStatusCode intValue],@" ",responseText);
    return;
}

CkoJsonObject *result = [[CkoJsonObject alloc] init];
success = [result Load: responseText];
if (success != YES) {
    NSLog(@"%@",result.LastErrorText);
    return;
}

if ([result BoolOf: @"VerifiedForSendingStatus"] == YES) {
    NSLog(@"%@",@"The identity is already verified for sending.");
}
else {
    NSLog(@"%@",@"Open the verification email from AWS, follow its link, then check the identity status.");
}