[Techtalk] delete mail from the server

noir noir acknak_halflife at yahoo.co.uk
Tue Dec 30 20:14:15 EST 2003


LOL, Rasjid. Thanks for the recommendation. But I find
it hard to believe s/o somewhere has not written
something like this! I will do a few more research and
if I fail to find anything, see you in the programming
list w/ a few stupid Perl questions :)
 
Regards,
Noir.
 
Rasjid Wilcox <rasjidw at openminddev.net> wrote:

On Tuesday 30 December 2003 23:51, Noir wrote:
> On Tue, Dec 30, 2003 at 11:45:11PM +1100, Rasjid
Wilcox wrote:
> > Keyword Opt Function
> >
------------------------------------------------------------
> > ...
> > limit -l Set message size limit
>
> Thanks. But that doesn't _delete_ the mail from the
server it only keeps
> from d.loading it.

Ah. Sorry, I misunderstood your original post. In this
case I'd recommend 
writing a Python or Perl script. If you don't know
either, I'd suggest 
Python.

I had a quick play with the python imaplib library.
You may want something 
along the following lines:

----
#!/usr/bin/env python

import imaplib
mail = imaplib.IMAP4('hostname')
mail.login('username', 'password')
mail.select()
typ, data = mail.search(None, 'LARGER', 1000000)
for num in data[0].split():
typ, data = mail.store(num, '+FLAGS', '\Deleted')
mail.expunge()
mail.close()
mail.logout()

-----

I have just done a quick test with this, and it seems
to work okay for me. 
Adjust the size used in the search command to suit.
The IMAP RFC (2060) 
talks about 'Octets', which as far as I can tell just
means 8 bit bytes.

Of course, the above assumes that you can make IMAP
connections to the mailbox 
in question, and not just POP3. Most ISPs seem to
provide IMAP connections 
now, even if they don't advertise the fact. (If they
offer a webmail 

 


________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html


More information about the Techtalk mailing list