thank you ianare for your perl Script, because I don't handle Perl, I wrote an python Script that delete all messages in an folder.. It worked good for my SPAM Folder and an Mailinglist Folder with 15k mails...
But no I have problems 2 other Foldes, my python Script get an search result of 0 mails, also I've I search for All mails...
But in the scalix webinterface and in Thunderbird I get all ~37.000 mails listed
What could be wrong?
Code: Select all
fho@schneewittchen:~/Documents/coding/scalix$ cat delmails.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Last modified: 04/12/07 11:37:28(CET) by Fabian Holler
import imaplib,string,sys
imapserver="scalix"
imapuser="fho@zensored"
imappasswd="zensored"
mailboxes=[ "logs", "logs/Logwatch", "logs/backup" ]
con=imaplib.IMAP4(imapserver)
con.login_cram_md5(imapuser,imappasswd)
result=""
for mailbox in mailboxes:
print "Mailbox: "+mailbox
if not con.select(mailbox,readonly=None)[0] == "OK":
print "Mailbox auswählen fehlgeschlagen"
sys.exit()
# typ, data = con.search(None,'(BEFORE 30-DEC-2009)') #Alle Mails löschen die älter sind als..
typ, data = con.search(None,'(UNSEEN)') #Alle Mails löschen
print data
count=0
for num in string.split(data[0]):
con.store(num,"+FLAGS.SILENT",'\DELETED')
print "Deleted message: "+num+" "+(con.fetch(num,'(BODY[HEADER.FIELDS(SUBJECT)])'))[1][0][1]
count+=1
con.expunge()
result+="\ndeleted "+str(count)+" messages in "+mailbox+"\n"
con.close()
con.logout()
print result