daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import imaplib
  2. import email
  3. print('imported')
  4.  
  5. mail = imaplib.IMAP4_SSL('imap.gmail.com',993)
  6.  
  7. user = 'xxxxxx@gmail.com'
  8. pwd = 'xxxxx'
  9.  
  10. mail.login(user,pwd)
  11. print('successfully logged in')
  12. mail.list()
  13. print(mail.list())
  14. print('selecting inbox')
  15.  
  16. mail.select('INBOX')
  17. print('inbox selected')
  18.  
  19. # selecting all items / emails
  20. result, data = mail.uid('search', None, "ALL")
  21.  
  22. # transforming tuple into list / splitting them
  23.  
  24. inbox_item_list = data[0].split()
  25.  
  26. inbox_item_list
  27.  
  28. result2, email_data = mail.uid('fetch', inbox_item_list, '(RFC822)')
  29.  
  30. # using regex to search for emails?
  31. # safe results into csv
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top