Advertisement
Guest User

Untitled

a guest
Sep 19th, 2011
225
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. # example@domain.com
  15. username = 'seulogin@gmail.com' # seu login
  16. password = 'suasenha' # sua senha
  17. mailbox = 'INBOX' # inbox is default
  18.  
  19. # only tested with gmail and my university email
  20. # it should work with any imap server
  21. # change mail server and port to match your server's info
  22. mailserver = 'imap.gmail.com'
  23. port = 993
  24.  
  25. # connect to gmail's server (uses SSL, port 993)
  26. server = imaplib.IMAP4_SSL(mailserver,port)
  27.  
  28. # gmail uses ssl...if your imap mail server doesn't comment the above
  29. # line and uncomment this one.
  30. # server = imaplib.IMAP4(mailserver,port)
  31.  
  32. # login with the variables provided up top
  33. server.login(username,password)
  34.  
  35. # select your mailbox
  36. server.select(mailbox)
  37.  
  38. # pull info for that mailbox
  39. data = str(server.status(mailbox, '(MESSAGES UNSEEN)'))
  40.  
  41. # print it all out
  42. print # escreva um nome para exibir
  43. print 'seunome@gmail.com'
  44. tokens = data.split()
  45.  
  46. # clean up output with str_replace()
  47. print 'Mensagens',tokens[3]
  48. print 'Nao lidas',tokens[5].replace(')\'])','')
  49. print
  50. # close the mailbox
  51. server.close()
  52.  
  53. # logout of the server
  54. server.logout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement