Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pythonpopflush [2014/10/26 01:52] (current)
Line 1: Line 1:
 +== Delete all messages from a POP3 mailbox ==
 +<code python>
 +#​!/​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()
 +
 +</​code>​
 +
 +----
 +
 +  * [[pythoninfo|Back to Python]]
  
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