Advertisement
Guest User

Untitled

a guest
Sep 19th, 2011
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. # Author: Bhavik Shah
  2. # Description: Simple script that uses the python imap library
  3. # to retrieve number of messages and unread messages from your
  4. # imap email account.
  5. ###########################################################################
  6. # Script retirado de: <http://bhaviksblog.com/03/have-conky-check-your-email/>
  7. # Editado e traduzido por Leandro NK <http://www.vivaolinux.com.br/perfil/verPerfil.php?login=%20leandro>
  8. import imaplib
  9.  
  10. # Username should be your username with '@gmail.com' added
  11. # I think the @gmail.com is required.
  12. # If you're trying it with something other than gmail
  13. # you should make the username the full email address
  14. username = '[email protected]' # seu login
  15. password = 'suasenha' # sua senha
  16. mailbox = 'INBOX' # inbox is default
  17.  
  18. # only tested with gmail and my university email
  19. # it should work with any imap server
  20. # change mail server and port to match your server's info
  21. mailserver = 'imap.gmail.com'
  22. port = 993
  23.  
  24. # connect to gmail's server (uses SSL, port 993)
  25. server = imaplib.IMAP4_SSL(mailserver,port)
  26.  
  27. # gmail uses ssl...if your imap mail server doesn't comment the above
  28. # line and uncomment this one.
  29. # server = imaplib.IMAP4(mailserver,port)
  30.  
  31. # login with the variables provided up top
  32. server.login(username,password)
  33.  
  34. # select your mailbox
  35. server.select(mailbox)
  36.  
  37. # pull info for that mailbox
  38. data = str(server.status(mailbox, '(MESSAGES UNSEEN)'))
  39.  
  40. # print it all out
  41. print # escreva um nome para exibir
  42. tokens = data.split()
  43.  
  44. # clean up output with str_replace()
  45. print 'Mensagens',tokens[3]
  46. print 'Nao lidas',tokens[5].replace(')\'])','')
  47. print
  48. # close the mailbox
  49. server.close()
  50.  
  51. # logout of the server
  52. server.logout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement