Advertisement
ktostupid

.gmail

May 21st, 2015
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: UTF-8 -*-
  3.  
  4. import sys, imaplib
  5.  
  6. port = 993
  7. server = 'imap.gmail.com'
  8.  
  9. username = 'stupid@gmail.com'
  10. passwd = 'pass'
  11.  
  12. imap_server = imaplib.IMAP4_SSL(server, port)
  13. try:
  14. imap_server.login(username, passwd)
  15. except:
  16. print('?? new')
  17. sys.exit( 1 )
  18.  
  19. typ, data = imap_server.select ('Inbox', True)
  20. if typ == 'OK':
  21. total = int(data[0])
  22. typ, data = imap_server.search (None, 'SEEN')
  23. if typ == 'OK':
  24. seen = len(data[0].split())
  25. print('{} new'.format(total - seen))
  26.  
  27. if typ != 'OK':
  28. print('?? new')
  29.  
  30. imap_server.logout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement