Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. from imaplib import IMAP4_SSL
  2. import email
  3. host = "mail.corp.itclover.ru"
  4. port = '993'
  5. user = "nujina.arina"
  6. password = "1Qwertyu"
  7.  
  8. connection = IMAP4_SSL(host=host, port=port)
  9. connection.login(user=user, password=password)
  10. status, msgs = connection.select('inbox')
  11. #print(msgs)
  12. # assert status == 'OK'
  13. #
  14. typ, data = connection.search(None, 'ALL')
  15. #print(data)
  16. for num in data[0].split():
  17. typ, message_data= connection.fetch(num, '(RFC822)')
  18. # print(data)
  19. # print('Message %s\n%s\n' % (num, message_data[0][1]))
  20.  
  21. mail = email.message_from_bytes(message_data[0][1])
  22. a = mail._payload[0]
  23. a=a._payload
  24. print(a)
  25. #print(a.encode('ascii'))
  26. #print(mail)
  27. # if mail.is_multipart():
  28. # for part in mail.walk():
  29. # content_type = part.get_content_type()
  30. # filename = part.get_filename()
  31. # if filename:
  32. # with open(part.get_filename(), 'wb') as new_file:
  33. # new_file.write(part.get_payload(decode=True))
  34. connection.close()
  35. connection.logout()
  36. #465
  37. #993
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement