-
Notifications
You must be signed in to change notification settings - Fork 0
/
staticus.py
31 lines (22 loc) · 877 Bytes
/
staticus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from requests import get
API_KEY = ""
MY_DOMAIN = "mailgun.net"
MY_STATUS_LIST = "status-updates@mailgun.net"
EVENTS_API_URL = "https://api.mailgun.net/v2/{}/events".format(MY_DOMAIN)
def main():
response = get(EVENTS_API_URL,
auth=('api', API_KEY),
params={
"event": "stored"
})
events = response.json()
message_urls = [event['storage']['url'] for event in events['items']
if MY_STATUS_LIST in event['message']['recipients']]
for url in message_urls:
message = get(url,
auth=('api', API_KEY)).json()
print "From: ", message['from']
print '--------------------------- {} --------------------------------'.format(message['subject'])
print message['body-plain']
if __name__ == "__main__":
main()