Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- HOST = 'imap.gmail.com'
- USERNAME = 'oldspiceap@gmail.com'
- PASSWORD = 'Iuyasdg387'
- PORT = '993'
- import subprocess
- import imaplib
- import re
- import os
- search_for_subject = 'eSellerate'
- im = imaplib.IMAP4_SSL(HOST, PORT)
- im.login(USERNAME, PASSWORD)
- im.select()
- result = im.search(None, "SUBJECT", search_for_subject)[1][0].split()
- RE = re.compile('^serial = (\d+)$', re.MULTILINE)
- for n in result:
- typ, data = im.fetch(n,'(RFC822)')
- body = data[0][1]
- # read the body here:
- """
- m = RE.search(body)
- if m:
- serial = m.group(1)
- print 'calling somescript', serial
- subprocess.call(['somescript', some_identifier_from_email])
- im.store(n, '+FLAGS', '\Deleted')
- """
- print body
- im.expunge()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement