Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL cRegion
LOCAL oHost
LOCAL oSigner
LOCAL oConnection
LOCAL oRest
LOCAL cSessionToken
LOCAL cResponseText
LOCAL oResponse
nSuccess := 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
nSuccess := 0
// Use the same AWS Region for the identity, endpoint, and Signature Version 4.
cRegion := "us-west-2"
oHost := CreateObject("Chilkat.StringBuilder")
oHost:Append("email.")
oHost:Append(cRegion)
oHost:Append(".amazonaws.com")
oSigner := CreateObject("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 := cRegion
oSigner:ServiceName := "ses"
oConnection := CreateObject("Chilkat.Socket")
oConnection:RequireSslCertVerify := 1
nSuccess := oConnection:Connect(oHost:GetAsString(), 443, 1, 10000)
IF (nSuccess != 1)
? oConnection:LastErrorText
oHost:destroy()
oSigner:destroy()
oConnection:destroy()
RETURN
ENDIF
oRest := CreateObject("Chilkat.Rest")
nSuccess := oRest:UseConnection(oConnection, 0)
IF (nSuccess != 1)
? oRest:LastErrorText
oHost:destroy()
oSigner:destroy()
oConnection:destroy()
oRest:destroy()
RETURN
ENDIF
nSuccess := oRest:SetAuthAws(oSigner)
IF (nSuccess != 1)
? oRest:LastErrorText
oHost:destroy()
oSigner:destroy()
oConnection:destroy()
oRest:destroy()
RETURN
ENDIF
// For temporary AWS credentials, supply the session token from the same provider.
cSessionToken := ""
IF (cSessionToken != "")
oRest:AddQueryParam("X-Amz-Security-Token", cSessionToken)
ENDIF
cResponseText := oRest:FullRequestNoBody("GET", "/v2/email/account")
IF (oRest:LastMethodSuccess != 1)
? oRest:LastErrorText
oHost:destroy()
oSigner:destroy()
oConnection:destroy()
oRest:destroy()
RETURN
ENDIF
IF (oRest:ResponseStatusCode != 200)
? "SES returned HTTP " + Str(oRest:ResponseStatusCode) + " " + cResponseText
oHost:destroy()
oSigner:destroy()
oConnection:destroy()
oRest:destroy()
RETURN
ENDIF
oResponse := CreateObject("Chilkat.JsonObject")
nSuccess := oResponse:Load(cResponseText)
IF (nSuccess != 1)
? oResponse:LastErrorText
oHost:destroy()
oSigner:destroy()
oConnection:destroy()
oRest:destroy()
oResponse:destroy()
RETURN
ENDIF
? "Sending enabled: " + Str(oResponse:BoolOf("SendingEnabled"))
? "Production access: " + Str(oResponse:BoolOf("ProductionAccessEnabled"))
? "Recipients sent to in the last 24 hours: " + oResponse:StringOf("SendQuota.SentLast24Hours")
? "24-hour recipient quota (-1 means unlimited): " + oResponse:StringOf("SendQuota.Max24HourSend")
? "Maximum recipients per second: " + oResponse:StringOf("SendQuota.MaxSendRate")
oHost:destroy()
oSigner:destroy()
oConnection:destroy()
oRest:destroy()
oResponse:destroy()