Unicode C++
Unicode C++
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 Unicode C++ Downloads
#include <CkStringBuilderW.h>
#include <CkAuthAwsW.h>
#include <CkSocketW.h>
#include <CkRestW.h>
#include <CkXmlW.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);
}
// 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(L"Action",L"GetIdentityVerificationAttributes");
rest.AddQueryParam(L"Version",L"2010-12-01");
rest.AddQueryParam(L"Identities.member.1",L"sender+reports@example.com");
const wchar_t *responseText = rest.fullRequestNoBody(L"GET",L"/");
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;
}
CkXmlW result;
success = result.LoadXml(responseText);
if (success != true) {
wprintf(L"%s\n",result.lastErrorText());
return;
}
// A map entry contains the identity as key and its verification attributes as value.
if (result.NumChildrenAt(L"GetIdentityVerificationAttributesResult|VerificationAttributes") < 1) {
wprintf(L"No verification entry returned for this address in this Region.\n");
return;
}
const wchar_t *status = result.getChildContent(L"GetIdentityVerificationAttributesResult|VerificationAttributes|entry|value|VerificationStatus");
wprintf(L"Verification status: %s\n",status);
if (status == L"Pending") {
wprintf(L"Open the AWS verification email and follow its link.\n");
}
}