Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- This script simply mass delete mails from a mailbox
- through a POP3 access.
- May be useful when you want to clear an Inbox of spams & all.
- ** CAUTION ** After you have selected the number of messages to delete and pressed
- Enter, it really does begin to delete the emails in a permanent way. (Without passing by a trash folder)
- Note: the removal is actual when the script close the POP3 connection
- with the QUIT command (if you provider correctly implements the POP3 protocol).
- Written by Yoan Tournade <yoan@ytotech.com>
- """
- import poplib
- POP_SERVER_URL = 'pop.empire.org'
- POP_SERVER_PORT = 995
- POP_USER = 'dark.vader@empire.org'
- POP_PASSWORD = 'I hate you!'
- popClient = poplib.POP3_SSL(POP_SERVER_URL, port=995)
- popClient.set_debuglevel(1)
- print(popClient.user(POP_USER))
- print(popClient.pass_(POP_PASSWORD))
- try:
- mailCount = popClient.stat()[0]
- print('There are {} mails in the inbox'.format(mailCount))
- numberToDelete = int(input('How many do you want to delete? '))
- print(numberToDelete)
- # print(popClient.list()[1])
- for i in range(1, numberToDelete):
- popClient.dele(i)
- print('{} DELE commands passed'.format(numberToDelete))
- finally:
- print('QUIT-ing')
- popClient.quit()
- print("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement