newbie question...
Fredrik Lundh
fredrik at pythonware.com
Tue Dec 28 08:15:58 EST 1999
Alexander Sendzimir <sendzimir at earthlink.net> wrote:
> According to David Beazley's invaluable book, mailbox.py
> is an undocumented module.
guess david missed this one:
http://www.python.org/doc/current/lib/module-mailbox.html
...
here's an example (from the eff-bot guide):
##
## mailbox-example-1.py
import mailbox
mb = mailbox.UnixMailbox(open("/var/spool/mail/effbot"))
while 1:
msg = mb.next()
if not msg:
break
for k, v in msg.items():
print k, "=", v
body = msg.fp.read()
print len(body), "bytes in body"
## sample output:
##
## subject = for he's a ...
## message-id = <199910150027.CAA03202 at spam.egg>
## received = (from fredrik at pythonware.com)
## by spam.egg (8.8.7/8.8.5) id CAA03202
## for effbot; Fri, 15 Oct 1999 02:27:36 +0200
## from = Fredrik Lundh <fredrik at pythonware.com>
## date = Fri, 15 Oct 1999 12:35:36 +0200
## to = effbot at spam.egg
## 1295 bytes in body
</F>
More information about the Python-list
mailing list