Created
July 21, 2016 23:27
-
-
Save glennzw/2d876a0c715634c9187ebe08426bf05b to your computer and use it in GitHub Desktop.
Monitor bounces from Amazon SES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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