Skip to content

Instantly share code, notes, and snippets.

@glennzw
Created July 21, 2016 23:27
Show Gist options
  • Save glennzw/2d876a0c715634c9187ebe08426bf05b to your computer and use it in GitHub Desktop.
Save glennzw/2d876a0c715634c9187ebe08426bf05b to your computer and use it in GitHub Desktop.
Monitor bounces from Amazon SES
#!/usr/bin/python
import boto.ses
import time
AWS_ACCESS_KEY = 'xxx'
AWS_SECRET_KEY = 'xxx'
conn = boto.ses.connect_to_region("us-west-2",aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY)
while True:
s = conn.get_send_statistics()
stats = s.get("GetSendStatisticsResponse", {}).get("GetSendStatisticsResult", {}).get("SendDataPoints")
if stats:
totalBounces = 0
for s in stats:
b = s.get("Bounces", "0")
totalBounces += int(b)
print "[+] Total bounces: %d" % totalBounces
time.sleep(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment