Mailbox cleaner on an IMAP basis?

F. GEIGER fgeiger at datec.at
Tue Sep 23 01:44:58 EDT 2003


Well, John,

I've stopped here, because I could not figure out how to get at the ids of
mails with attachments. And if I had that missing link, I'd run into the
next hindrance: How can I delete a single message? IMAP4::delete() deletes a
whole mailbox, not just a single mail.

So my code really is only a few lines so far:

i = IMAP4(myDomain)
i.login(myUser, myPassword)
i.select() # Select INBOX
r, d = i.fetch(1, "(BODY.PEEK[HEADER.FIELDS])") # Check 1st mail

Seems I have to get a book about IMAP and how to use it...

Kind regards
Franz




"John Roth" <newsgroups at jhrothjr.com> schrieb im Newsbeitrag
news:vmuhsrr68tlj27 at news.supernews.com...
>
> "F. GEIGER" <fgeiger at datec.at> wrote in message
> news:3f6f2cfb at news.swissonline.ch...
> > Hi all!
> >
> > As I saw Alex Martelli's post about a mbox cleaner based on POP3, I
> thought,
> > it could be possible to do that based on IMAP too. That way I could ask
> the
> > server for mails having attached EXE files and delete all those mails on
> the
> > server. This would save me a lot of traffic over my phone line
connection.
> >
> > But I'm missing one important thing: How do I get the server to tell me
> > about attachments.
> >
> > What I've found out so far is how to get at the fields:
> >
> > r, d = i.fetch(1, "(BODY.PEEK[HEADER.FIELDS])")
> >
> > Alas, there's no such thing like 'filename' or 'attachments'.
> >
> > And
> >
> > r, d = i.fetch(1, "(BODY.PEEK[HEADER.FIELDS (Content-type)])")
> >
> > doesn't show a file name either.
> >
> > Any hints?
>
> Right now, I'd simply like something that would clean out an
> IMAP mailbox on a regular basis. Most of the worm generated
> garbage is going into one of two boxes on my server, and I get maybe
> one legitimate e-mail in those two boxes every couple of weeks.
> I can stand to lose that level of e-mail, I can't stand to exceed my disk
> quota and lose lots of legitimate mail every few hours.
>
> Could you post the code you've got so far?
>
> Thanks.
>
> John Roth
> >
> > Best regards
> > Franz GEIGER
> >
> >
> >
> >
> >
>
>






More information about the Python-list mailing list