Sample code for 30+ languages & platforms
Classic ASP

Amazon SES v2: Check an address on the account suppression list

See more Amazon SES Examples

Look up one address in the sending Region with ses:GetSuppressedDestination. The record distinguishes a bounce from a complaint. An absent record tells you only that this account suppression lookup found no entry. The example signs the exact encoded mailbox path and also works with temporary credentials.

GetSuppressedDestination

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.
success = 0

'  Look up the address exactly as stored, including any plus tag.
address = "avery+orders@example.com"
region = "us-west-2"
accessKey = "AWS_ACCESS_KEY_ID"
secretKey = "AWS_SECRET_ACCESS_KEY"
sessionToken = ""
set host = Server.CreateObject("Chilkat.StringBuilder")
success = host.Append("email.")
success = host.Append(region)
success = host.Append(".amazonaws.com")
set mailbox = Server.CreateObject("Chilkat.StringBuilder")
success = mailbox.Append(address)
set path = Server.CreateObject("Chilkat.StringBuilder")
success = path.Append("/v2/email/suppression/addresses/")
success = path.Append(mailbox.GetEncoded("url_rfc3986","utf-8"))

'  SigV4 for SES encodes the wire path a second time in the canonical request.
'  Only the canonical copy escapes the percent signs. Send the original path over HTTPS.
set canonicalPath = Server.CreateObject("Chilkat.StringBuilder")
success = canonicalPath.Append(path.GetAsString())
replaced = canonicalPath.Replace("%","%25")
set clock = Server.CreateObject("Chilkat.CkDateTime")
success = clock.SetFromCurrentSystemTime()
set stamp = Server.CreateObject("Chilkat.StringBuilder")
success = stamp.Append(clock.GetAsTimestamp(0))
replaced = stamp.Replace("-","")
replaced = stamp.Replace(":","")
date = stamp.GetRange(0,8,0)
set rest = Server.CreateObject("Chilkat.Rest")
success = rest.AddHeader("Host",host.GetAsString())
success = rest.AddHeader("x-amz-date",stamp.GetAsString())
set headers = Server.CreateObject("Chilkat.StringBuilder")
success = headers.Append("host:")
success = headers.Append(host.GetAsString())
success = headers.Append(vbLf & "x-amz-date:")
success = headers.Append(stamp.GetAsString())
success = headers.Append(vbLf)
signedHeaders = "host;x-amz-date"
If (sessionToken <> "") Then
    success = rest.AddHeader("x-amz-security-token",sessionToken)
    success = headers.Append("x-amz-security-token:")
    success = headers.Append(sessionToken)
    success = headers.Append(vbLf)
    signedHeaders = "host;x-amz-date;x-amz-security-token"
End If

set crypto = Server.CreateObject("Chilkat.Crypt2")
crypto.HashAlgorithm = "sha256"
crypto.MacAlgorithm = "hmac"
crypto.EncodingMode = "hexlower"
crypto.Charset = "utf-8"
set canonical = Server.CreateObject("Chilkat.StringBuilder")
success = canonical.Append("GET" & vbLf)
success = canonical.Append(canonicalPath.GetAsString())
success = canonical.Append(vbLf & vbLf)
success = canonical.Append(headers.GetAsString())
success = canonical.Append(vbLf)
success = canonical.Append(signedHeaders)
success = canonical.Append(vbLf)
success = canonical.Append(crypto.HashStringENC(""))
set scope = Server.CreateObject("Chilkat.StringBuilder")
success = scope.Append(date)
success = scope.Append("/")
success = scope.Append(region)
success = scope.Append("/ses/aws4_request")
set toSign = Server.CreateObject("Chilkat.StringBuilder")
success = toSign.Append("AWS4-HMAC-SHA256" & vbLf)
success = toSign.Append(stamp.GetAsString())
success = toSign.Append(vbLf)
success = toSign.Append(scope.GetAsString())
success = toSign.Append(vbLf)
success = toSign.Append(crypto.HashStringENC(canonical.GetAsString()))

'  Derive the signing key one HMAC at a time. Decode each intermediate key from hex.
set seed = Server.CreateObject("Chilkat.StringBuilder")
success = seed.Append("AWS4")
success = seed.Append(secretKey)
success = crypto.SetMacKeyString(seed.GetAsString())
key = crypto.MacStringENC(date)
success = crypto.SetMacKeyEncoded(key,"hex")
key = crypto.MacStringENC(region)
success = crypto.SetMacKeyEncoded(key,"hex")
key = crypto.MacStringENC("ses")
success = crypto.SetMacKeyEncoded(key,"hex")
key = crypto.MacStringENC("aws4_request")
success = crypto.SetMacKeyEncoded(key,"hex")
signature = crypto.MacStringENC(toSign.GetAsString())
set authorization = Server.CreateObject("Chilkat.StringBuilder")
success = authorization.Append("AWS4-HMAC-SHA256 Credential=")
success = authorization.Append(accessKey)
success = authorization.Append("/")
success = authorization.Append(scope.GetAsString())
success = authorization.Append(", SignedHeaders=")
success = authorization.Append(signedHeaders)
success = authorization.Append(", Signature=")
success = authorization.Append(signature)
success = rest.AddHeader("Authorization",authorization.GetAsString())
set connection = Server.CreateObject("Chilkat.Socket")
connection.RequireSslCertVerify = 1
success = connection.Connect(host.GetAsString(),443,1,10000)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( connection.LastErrorText) & "</pre>"
    Response.End
End If

success = rest.UseConnection(connection,0)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
End If

responseText = rest.FullRequestNoBody("GET",path.GetAsString())
If (rest.LastMethodSuccess <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
End If

If (rest.ResponseStatusCode = 404) Then
    Response.Write "<pre>" & Server.HTMLEncode( "No account suppression entry for this address in this Region.") & "</pre>"
    Response.End
End If

If (rest.ResponseStatusCode <> 200) Then
    Response.Write "<pre>" & Server.HTMLEncode( "SES returned HTTP " & rest.ResponseStatusCode & " " & responseText) & "</pre>"
    Response.End
End If

ERROR: ASP example cannot use request or response as a variable name.
success = response.Load(responseText)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( response.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( response.StringOf("SuppressedDestination.EmailAddress")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Reason: " & response.StringOf("SuppressedDestination.Reason")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Last updated (Unix seconds): " & response.StringOf("SuppressedDestination.LastUpdateTime")) & "</pre>"

%>
</body>
</html>