Objective-C
Objective-C
Amazon SES v2: Check regional sending access and quota
See more Amazon SES Examples
Run this in the Region where your application sends mail. Check whether SES accepts sends, whether the account has production access, and how much of its rolling 24-hour quota is in use. Sandbox accounts can send to verified recipients and the mailbox simulator. Sender verification is regional.
GetAccount · Sandbox restrictions
Chilkat Objective-C Downloads
#import <NSString.h>
#import <CkoStringBuilder.h>
#import <CkoAuthAws.h>
#import <CkoSocket.h>
#import <CkoRest.h>
#import <CkoJsonObject.h>
BOOL success = NO;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
success = NO;
// 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];
}
NSString *responseText = [rest FullRequestNoBody: @"GET" uriPath: @"/v2/email/account"];
if (rest.LastMethodSuccess != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
if ([rest.ResponseStatusCode intValue] != 200) {
NSLog(@"%@%d%@%@",@"SES returned HTTP ",[rest.ResponseStatusCode intValue],@" ",responseText);
return;
}
CkoJsonObject *response = [[CkoJsonObject alloc] init];
success = [response Load: responseText];
if (success != YES) {
NSLog(@"%@",response.LastErrorText);
return;
}
NSLog(@"%@%d",@"Sending enabled: ",[response BoolOf: @"SendingEnabled"]);
NSLog(@"%@%d",@"Production access: ",[response BoolOf: @"ProductionAccessEnabled"]);
NSLog(@"%@%@",@"Recipients sent to in the last 24 hours: ",[response StringOf: @"SendQuota.SentLast24Hours"]);
NSLog(@"%@%@",@"24-hour recipient quota (-1 means unlimited): ",[response StringOf: @"SendQuota.Max24HourSend"]);
NSLog(@"%@%@",@"Maximum recipients per second: ",[response StringOf: @"SendQuota.MaxSendRate"]);