Guest User

Untitled

a guest
Apr 26th, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import imaplib
  2. import base64
  3.  
  4. email_user = input('Email: ') # iamanwander@gmail.com
  5. email_pass = input('Password: ') #aman@cbtl22
  6.  
  7. M = imaplib.IMAP4_SSL('imap.gmail.com', 993)
  8. M.login(email_user, email_pass)
  9. M.select()
  10.  
  11. typ, message_numbers = M.search(None, 'ALL')
  12.  
  13. for num in message_numbers[0].split():
  14. typ, data = M.fetch(num, '(RFC822)')
  15. # num1 = base64.b64decode(num) # unnecessary, I think
  16. print(data) # check what you've actually got. That will help with the next line
  17. data1 = base64.b64decode(data[0][1])
  18. print('Message %s\n%s\n' % (num, data1))
  19.  
  20. M.close()
  21. M.logout()
Add Comment
Please, Sign In to add comment