Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perl & mail headers

by sgifford (Prior)
on Apr 30, 2004 at 04:55 UTC ( [id://349335]=note: print w/replies, xml ) Need Help??


in reply to Perl & mail headers

Unix mailboxes are flat files. Each message starts with the pattern:
/^From /
Immediately following the From_ are the message headers, followed by a blank line, followed by the body of the message. The message ends at the next From_ or at EOF.

As Stevie-O suggests, you'll probably want to use a mail parsing module for this. It's not that hard to write your own, but almost nobody gets it right the first time, and it's easier to just use one of the modules

Replies are listed 'Best First'.
Re: Re: Perl & mail headers
by nothingmuch (Priest) on Apr 30, 2004 at 13:29 UTC
    Lines in the messages matching /^From / should be escaped (with a dash), but it's usually better to pay attention to the Content-Length and Content-Lines headers, provided they exist.

    Please note that rolling your own can cause some unexpected damage, and that it's been done already (usually pretty well (and many times over)), and made available on the CPAN (see the previous posts).

    Good luck!

    -nuffin
    zz zZ Z Z #!perl
Re: Re: Perl & mail headers
by zakzebrowski (Curate) on Apr 30, 2004 at 12:25 UTC
    ++ Thanks for the explanation. I was wondering what the file format actually was for mbox. Makes a lot of sense. Cheers!


    ----
    Zak - the office

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://349335]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-18 22:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found