AutoIt
AutoIt
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 AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$bSuccess = False
; Use an address whose inbox you can open. SES sends the verification link there.
$oRequest = ObjCreate("Chilkat.JsonObject")
$oRequest.UpdateString("EmailIdentity","sender+reports@example.com")
; Use the same AWS Region for the identity, endpoint, and Signature Version 4.
Local $sRegion = "us-west-2"
$oHost = ObjCreate("Chilkat.StringBuilder")
$oHost.Append("email.")
$oHost.Append($sRegion)
$oHost.Append(".amazonaws.com")
$oSigner = ObjCreate("Chilkat.AuthAws")
; Supply the credentials from your application's credential provider.
$oSigner.AccessKey = "AWS_ACCESS_KEY_ID"
$oSigner.SecretKey = "AWS_SECRET_ACCESS_KEY"
$oSigner.Region = $sRegion
$oSigner.ServiceName = "ses"
$oConnection = ObjCreate("Chilkat.Socket")
$oConnection.RequireSslCertVerify = True
$bSuccess = $oConnection.Connect($oHost.GetAsString(),443,True,10000)
If ($bSuccess <> True) Then
ConsoleWrite($oConnection.LastErrorText & @CRLF)
Exit
EndIf
$oRest = ObjCreate("Chilkat.Rest")
$bSuccess = $oRest.UseConnection($oConnection,False)
If ($bSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oRest.SetAuthAws($oSigner)
If ($bSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
; For temporary AWS credentials, supply the session token from the same provider.
Local $sessionToken = ""
If ($sessionToken <> "") Then
$oRest.AddQueryParam("X-Amz-Security-Token",$sessionToken)
EndIf
$oRest.AddHeader("Content-Type","application/json")
Local $sResponseText = $oRest.FullRequestString("POST","/v2/email/identities",$oRequest.Emit())
If ($oRest.LastMethodSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
If ($oRest.ResponseStatusCode = 409) Then
ConsoleWrite("This identity already exists in this Region. Check its verification status." & @CRLF)
Exit
EndIf
If ($oRest.ResponseStatusCode <> 200) Then
ConsoleWrite("SES returned HTTP " & $oRest.ResponseStatusCode & " " & $sResponseText & @CRLF)
Exit
EndIf
$oResult = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oResult.Load($sResponseText)
If ($bSuccess <> True) Then
ConsoleWrite($oResult.LastErrorText & @CRLF)
Exit
EndIf
If ($oResult.BoolOf("VerifiedForSendingStatus") = True) Then
ConsoleWrite("The identity is already verified for sending." & @CRLF)
Else
ConsoleWrite("Open the verification email from AWS, follow its link, then check the identity status." & @CRLF)
EndIf