Advertisement
Guest User

Untitled

a guest
May 4th, 2017
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. HOST = 'imap.gmail.com'
  4. USERNAME = 'oldspiceap@gmail.com'
  5. PASSWORD = 'Iuyasdg387'
  6. PORT = '993'
  7.  
  8. import subprocess
  9. import imaplib
  10. import re
  11. import os
  12.  
  13. search_for_subject = 'eSellerate'
  14.  
  15. im = imaplib.IMAP4_SSL(HOST, PORT)
  16. im.login(USERNAME, PASSWORD)
  17. im.select()
  18.  
  19. result = im.search(None, "SUBJECT", search_for_subject)[1][0].split()
  20.  
  21. RE = re.compile('^serial = (\d+)$', re.MULTILINE)
  22.  
  23. for n in result:
  24. typ, data = im.fetch(n,'(RFC822)')
  25. body = data[0][1]
  26.  
  27. # read the body here:
  28.  
  29. """
  30. m = RE.search(body)
  31. if m:
  32. serial = m.group(1)
  33. print 'calling somescript', serial
  34. subprocess.call(['somescript', some_identifier_from_email])
  35. im.store(n, '+FLAGS', '\Deleted')
  36. """
  37.  
  38. print body
  39.  
  40. im.expunge()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement