daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Mar 20th, 2017 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. This script simply mass delete mails from a mailbox
  3. through a POP3 access.
  4.  
  5. May be useful when you want to clear an Inbox of spams & all.
  6.  
  7. ** CAUTION ** After you have selected the number of messages to delete and pressed
  8. Enter, it really does begin to delete the emails in a permanent way. (Without passing by a trash folder)
  9.  
  10. Note: the removal is actual when the script close the POP3 connection
  11. with the QUIT command (if you provider correctly implements the POP3 protocol).
  12.  
  13. Written by Yoan Tournade <yoan@ytotech.com>
  14. """
  15. import poplib
  16.  
  17. POP_SERVER_URL = 'pop.empire.org'
  18. POP_SERVER_PORT = 995
  19. POP_USER = 'dark.vader@empire.org'
  20. POP_PASSWORD = 'I hate you!'
  21.  
  22. popClient = poplib.POP3_SSL(POP_SERVER_URL, port=995)
  23. popClient.set_debuglevel(1)
  24. print(popClient.user(POP_USER))
  25. print(popClient.pass_(POP_PASSWORD))
  26. try:
  27.     mailCount = popClient.stat()[0]
  28.     print('There are {} mails in the inbox'.format(mailCount))
  29.     numberToDelete = int(input('How many do you want to delete? '))
  30.     print(numberToDelete)
  31.     # print(popClient.list()[1])
  32.     for i in range(1, numberToDelete):
  33.         popClient.dele(i)
  34.     print('{} DELE commands passed'.format(numberToDelete))
  35. finally:
  36.     print('QUIT-ing')
  37.     popClient.quit()
  38.  
  39. print("Done")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top