␡
- The rfc822 Module
- A Simple DTD for E-mail
- An Example of an E-mail Message in XML
- Processing a Eudora Mailbox
- Processing a Linux Mailbox
- Processing an E-mail Message by Using the rfc822 Module
- Sending E-mail by Using xMail
- Source Code for the SendxMail Application
- Source Code for the xMail Application
This chapter is from the book
14.5 | Processing a Linux Mailbox
To process a Linux-style mailbox into individual messages, a different control structure is required. Note, however, that the processing of each individual e-mail is handled by ProcessMessage, which is common to both Linux and Eudora converters.
CD-ROM reference=14006.txt DoLinuxMailBox(f): # f is a file object. L = f.readline()[:-1] if string.find(L,"From ")!=0: -print 'Expected mailbox "%s" to start with "From "' % MailBox return Message = [] L = f.readline() while L: if string.find(L,"From ")==0: -# Full message accumulated in the Message # list, so process it to XML ProcessMessage(Message,out) Message = [] else: # Accumulate e-mail contents line by line in # Message list. Message.append (L) L = f.readline() if Message: # Last message in the mailbox ProcessMessage(Message,out)