Advertisement
Guest User

Untitled

a guest
Nov 11th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import email
  2. import imaplib
  3.  
  4.  
  5. server = "imap.mail.ru"
  6. port = "993"
  7. password = "moms_lover"
  8. imaplib.Debug = 4
  9. get_mail = imaplib.IMAP4_SSL(server, port)
  10. get_mail.login(login, password)
  11. get_mail.select('INBOX', readonly=True)
  12. typ, data = get_mail.search(None, 'UNSEEN')
  13. for i in data[0].split():
  14. typ, data = get_mail.fetch(i, '(RFC822)')
  15. print(data[0][1])
  16. msg_string = data[0][1].decode('utf-8')
  17. msg = email.message_from_string(msg_string)
  18. for part in msg.walk():
  19. if part.get_content_type() == "text/plain":
  20. txt_msg = part.get_payload()
  21. print(txt_msg)
  22. else:
  23. continue
  24. get_mail.close()
  25. get_mail.logout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement