Delphi DLL
Delphi DLL
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 Delphi DLL Downloads
var
success: Boolean;
region: PWideChar;
host: HCkStringBuilder;
signer: HCkAuthAws;
connection: HCkSocket;
rest: HCkRest;
sessionToken: PWideChar;
responseText: PWideChar;
result: HCkXml;
status: PWideChar;
begin
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.
region := 'us-west-2';
host := CkStringBuilder_Create();
CkStringBuilder_Append(host,'email.');
CkStringBuilder_Append(host,region);
CkStringBuilder_Append(host,'.amazonaws.com');
signer := CkAuthAws_Create();
// Supply the credentials from your application's credential provider.
CkAuthAws_putAccessKey(signer,'AWS_ACCESS_KEY_ID');
CkAuthAws_putSecretKey(signer,'AWS_SECRET_ACCESS_KEY');
CkAuthAws_putRegion(signer,region);
CkAuthAws_putServiceName(signer,'ses');
connection := CkSocket_Create();
CkSocket_putRequireSslCertVerify(connection,True);
success := CkSocket_Connect(connection,CkStringBuilder__getAsString(host),443,True,10000);
if (success <> True) then
begin
Memo1.Lines.Add(CkSocket__lastErrorText(connection));
Exit;
end;
rest := CkRest_Create();
success := CkRest_UseConnection(rest,connection,False);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
success := CkRest_SetAuthAws(rest,signer);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
// For temporary AWS credentials, supply the session token from the same provider.
sessionToken := '';
if (sessionToken <> '') then
begin
CkRest_AddQueryParam(rest,'X-Amz-Security-Token',sessionToken);
end;
// 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.
CkRest_AddQueryParam(rest,'Action','GetIdentityVerificationAttributes');
CkRest_AddQueryParam(rest,'Version','2010-12-01');
CkRest_AddQueryParam(rest,'Identities.member.1','sender+reports@example.com');
responseText := CkRest__fullRequestNoBody(rest,'GET','/');
if (CkRest_getLastMethodSuccess(rest) <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
if (CkRest_getResponseStatusCode(rest) <> 200) then
begin
Memo1.Lines.Add('SES returned HTTP ' + IntToStr(CkRest_getResponseStatusCode(rest)) + ' ' + responseText);
Exit;
end;
result := CkXml_Create();
success := CkXml_LoadXml(result,responseText);
if (success <> True) then
begin
Memo1.Lines.Add(CkXml__lastErrorText(result));
Exit;
end;
// A map entry contains the identity as key and its verification attributes as value.
if (CkXml_NumChildrenAt(result,'GetIdentityVerificationAttributesResult|VerificationAttributes') < 1) then
begin
Memo1.Lines.Add('No verification entry returned for this address in this Region.');
Exit;
end;
status := CkXml__getChildContent(result,'GetIdentityVerificationAttributesResult|VerificationAttributes|entry|value|VerificationStatus');
Memo1.Lines.Add('Verification status: ' + status);
if (status = 'Pending') then
begin
Memo1.Lines.Add('Open the AWS verification email and follow its link.');
end;
CkStringBuilder_Dispose(host);
CkAuthAws_Dispose(signer);
CkSocket_Dispose(connection);
CkRest_Dispose(rest);
CkXml_Dispose(result);