Reading message size

Edvard Majakari edvard+news at majakari.net
Wed Aug 4 03:54:31 EDT 2004


I'm trying to create an improved front-end for training messages for a
spam filter. I discovered an excellent Python module email - now it's so
easy to support variety of mailbox formats. However, I need to know exact
size of the message (in bytes) and skip the message if it is too large,
before passing the message to filter.

This is easy with MH or Maildir style directories - because each message
is on separate file, it is trivial to get the file size. However, with
mbox or any other format containing several messages in a file, I'm unable
to find out individual message size.

Of course, I could find this out by writing a message to a temp file and
afterwards checking the temp file size, but I think that's awkward and
inelegant. Is it somehow possible with email module?

-- 
# Edvard Majakari		Software Engineer
# PGP PUBLIC KEY available    	Soli Deo Gloria!

$_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print
join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),"\n";




More information about the Python-list mailing list