Delete all messages from a POP3 mailbox
#!/usr/bin/python
 
import poplib
 
accounts = [
	{ 'server' : 'mail.engineer.com',
	  'user' : 'user1@engineer.com',
	  'pass' : 'secret'
	 },
	 { 'server' : 'mail.python.com',
	   'user' : 'user@python.com',
	   'pass' : 'Secret'
	 }
	 ]
 
#print str(accounts)
for ac in accounts:
	print 'Handle %s' % ac['server']
	pop = poplib.POP3(ac['server'])
	pop.user(ac['user'])
	pop.pass_(ac['pass'])
	(count, sz) = pop.stat()
	for i in range(1,count+1):
		pop.dele(i)
		print "%s: Delete %d" % (ac['server'],i)
	pop.quit()

pythonpopflush.txt · Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0