in reply to Parsing Pegasus email boxes

Hi graff,

Yes, most of the 'conversion' tools for Pegasus are for address book conversion, and none of the ones I previously looked for said "Pegasus --> Unix". However, following the link you supplied and doing a bit more research, I finally realised that Eudora mailboxes are Unix format, and there _are_ a few tools to go either way (Eudora<-->Pegasus), so that means if one converted a Pegasus mailbox to Eudora, we end up with a Unix mailbox. :)

I didn't find anything useful about the Pegasus file format (but did find some indications that the format specs would not be open to public inspection).

I've found the Pegasus discussion list very active in the past, and very helpful, and would be surprised if someone wouldn't know the layout. That said, I had my own look at them, as follows:

1. The first 96 bytes contains: * Folder description, right filled with lowecase 'a' * Other folder/hiearchy info * More lowercase 'a' to pad to the right 2. Then the format appears (to me) to be the same as Unix 3. The message termination seems to be indicated by: * hex OD OA OD OA 1A * CR LF CR LF -> 4. From '3', it is only the hex '1A' value that could indicate the msg + terminator, because email bodies could have two CR/LF's anywhere. 5. I don't know if any encoding would contain hex '1A" though, so look +ing for the 5 character string (in hex) would be safer, plus looking +at the next line (record) in the mailbox, it would be something like +"X-Apparently-To: "

Some other links I found on the conversion tools side are:

http://www.andtechnologies.com/free.html
http://www.interguru.com/MailInformation.htm
http://www.dragon-it.co.uk/pegasus.htm

You mentioned Mail::Address would be good, considering some dependencies. It's just that the Pegasus format is a _bit_ different, really just the first 96 bytes to ignore, and sort out the msg terminator. Hmm, my apologies, I just tried your sample code on a Pegasus mailbox and it dumped (printed) all the email names/address, thanks.

I see what you mean by multi-token address, addresses that are of many formats, and ones that are split over two lines; no doubt this can be a problem. :)

Peter

Replies are listed 'Best First'.
Re: Re: Parsing Pegasus email boxes
by graff (Chancellor) on Nov 17, 2003 at 02:13 UTC
    So, if you are fairly confident about the character string that marks the end of each mail message in this file format, then the perl code that would step through a file one message at a time would be pretty simple:
    { open( IN, "pegasus.file" ) or die $!; local $/ = "\x1a"; # change the input record separator while (<IN>) # $_ now contains one whole message, { # up to and including \x1a # do what you want with the message # including, if you like: @lines = split /\n/; # work on lines # or you could strip off the pegasus header stuff # and treat the remainder as if it were vanilla email # (just like you'd get with common unix mail tools) } } # record separator now reverts back to default
      Hi,

      Thanks, that code worked okay. I think I now need to do some serious reading up on working with arrays and strings. :)

      Peter