Unicode C++
Unicode 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 Unicode C++ Downloads
#include <CkStringBuilderW.h>
#include <CkAuthAwsW.h>
#include <CkSocketW.h>
#include <CkRestW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
bool success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
success = false;
// Use the same AWS Region for the identity, endpoint, and Signature Version 4.
const wchar_t *region = L"us-west-2";
CkStringBuilderW host;
host.Append(L"email.");
host.Append(region);
host.Append(L".amazonaws.com");
CkAuthAwsW signer;
// Supply the credentials from your application's credential provider.
signer.put_AccessKey(L"AWS_ACCESS_KEY_ID");
signer.put_SecretKey(L"AWS_SECRET_ACCESS_KEY");
signer.put_Region(region);
signer.put_ServiceName(L"ses");
CkSocketW connection;
connection.put_RequireSslCertVerify(true);
success = connection.Connect(host.getAsString(),443,true,10000);
if (success != true) {
wprintf(L"%s\n",connection.lastErrorText());
return;
}
CkRestW rest;
success = rest.UseConnection(connection,false);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
success = rest.SetAuthAws(signer);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
// For temporary AWS credentials, supply the session token from the same provider.
const wchar_t *sessionToken = L"";
if (sessionToken != L"") {
rest.AddQueryParam(L"X-Amz-Security-Token",sessionToken);
}
const wchar_t *responseText = rest.fullRequestNoBody(L"GET",L"/v2/email/account");
if (rest.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
if (rest.get_ResponseStatusCode() != 200) {
wprintf(L"SES returned HTTP %d %s\n",rest.get_ResponseStatusCode(),responseText);
return;
}
CkJsonObjectW response;
success = response.Load(responseText);
if (success != true) {
wprintf(L"%s\n",response.lastErrorText());
return;
}
wprintf(L"Sending enabled: %d\n",response.BoolOf(L"SendingEnabled"));
wprintf(L"Production access: %d\n",response.BoolOf(L"ProductionAccessEnabled"));
wprintf(L"Recipients sent to in the last 24 hours: %s\n",response.stringOf(L"SendQuota.SentLast24Hours"));
wprintf(L"24-hour recipient quota (-1 means unlimited): %s\n",response.stringOf(L"SendQuota.Max24HourSend"));
wprintf(L"Maximum recipients per second: %s\n",response.stringOf(L"SendQuota.MaxSendRate"));
}