MIME::Tools - Getting All MIME Header Info for a Message 
Author Message
 MIME::Tools - Getting All MIME Header Info for a Message

I'm interested in getting all MIME part information for e-mail messages.
I'm currently using MIME::Parser->parse(\*MSG), but that method
extracts/decodes all attachments to disk, which can take a fair amount
of time. Is there a method/methods I'm overlooking that can simply get
*all* of  the MIME information without doing the attachment decoding?
(I'm stressing "all", as MIME::Head can get the information for a given
header, but seeking out *all* headers seems like a more significant
undertaking (which I won't do if someone else has already done it).

Thanks in advance.



Sun, 07 Mar 2004 02:42:18 GMT  
 MIME::Tools - Getting All MIME Header Info for a Message

Quote:
> I'm interested in getting all MIME part information for e-mail messages.
> I'm currently using MIME::Parser->parse(\*MSG), but that method
> extracts/decodes all attachments to disk, which can take a fair amount
> of time. Is there a method/methods I'm overlooking that can simply get
> *all* of  the MIME information without doing the attachment decoding?
> (I'm stressing "all", as MIME::Head can get the information for a given
> header, but seeking out *all* headers seems like a more significant
> undertaking (which I won't do if someone else has already done it).

> Thanks in advance.

Just look at all the lines which precede the first blank line - those
are the headers.

-Gerard
http://www.lanois.com/perl/

-----=  Posted via Newsfeeds.Com, Uncensored Usenet News  =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
 Check out our new Unlimited Server. No Download or Time Limits!
-----==  Over 80,000 Newsgroups - 19 Different Servers!  ==-----



Sun, 07 Mar 2004 03:20:56 GMT  
 MIME::Tools - Getting All MIME Header Info for a Message

Quote:


> > I'm interested in getting all MIME part information for e-mail messages.
> > I'm currently using MIME::Parser->parse(\*MSG), but that method
> > extracts/decodes all attachments to disk, which can take a fair amount
> > of time. Is there a method/methods I'm overlooking that can simply get
> > *all* of  the MIME information without doing the attachment decoding?
> > (I'm stressing "all", as MIME::Head can get the information for a given
> > header, but seeking out *all* headers seems like a more significant
> > undertaking (which I won't do if someone else has already done it).

> > Thanks in advance.

> Just look at all the lines which precede the first blank line - those
> are the headers.

Right. But MIME headers can be found throughout a message - one set of headers
for every message part. So how to find them all? There are boundary markers
which can be used, but this can get complicated if you've got message/rfc822
parts, since those parts may well have their own boundaries and parts and some
of those parts can have message/rfc822 parts, etc. There are also various
default situations to keep in mind - cases with empty headers, etc. I may well
need to sort this all out myself, but I'm just checking to see if anyone has
already done this.

GK



Sun, 07 Mar 2004 04:50:05 GMT  
 MIME::Tools - Getting All MIME Header Info for a Message

Quote:

> I'm interested in getting all MIME part information for e-mail messages.
> I'm currently using MIME::Parser->parse(\*MSG), but that method
> extracts/decodes all attachments to disk, which can take a fair amount
> of time. Is there a method/methods I'm overlooking that can simply get
> *all* of  the MIME information without doing the attachment decoding?
> (I'm stressing "all", as MIME::Head can get the information for a given
> header, but seeking out *all* headers seems like a more significant
> undertaking (which I won't do if someone else has already done it).

You can tell MIME::Parser how to handle the parsed data. As default it
puts them somewhere on disk. Hence, before parsing, call

        $parser->output_to_core(1);

As for iterating over all MIME-parts (and the headers thereof), use the
parts or parts_DFS method.

my $parser  = new MIME::Parser; $parser->output_to_core(1);
my $top_ent = $parser->parse(\*STREAM);



you want with it.

Tassilo

--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->

(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108


ord(chr($h->{$_}))))};



Sun, 07 Mar 2004 14:18:07 GMT  
 MIME::Tools - Getting All MIME Header Info for a Message

Quote:


> > I'm interested in getting all MIME part information for e-mail messages.
> > I'm currently using MIME::Parser->parse(\*MSG), but that method
> > extracts/decodes all attachments to disk, which can take a fair amount
> > of time. Is there a method/methods I'm overlooking that can simply get
> > *all* of  the MIME information without doing the attachment decoding?
> > (I'm stressing "all", as MIME::Head can get the information for a given
> > header, but seeking out *all* headers seems like a more significant
> > undertaking (which I won't do if someone else has already done it).

> You can tell MIME::Parser how to handle the parsed data. As default it
> puts them somewhere on disk. Hence, before parsing, call

>         $parser->output_to_core(1);

> As for iterating over all MIME-parts (and the headers thereof), use the
> parts or parts_DFS method.

> my $parser  = new MIME::Parser; $parser->output_to_core(1);
> my $top_ent = $parser->parse(\*STREAM);



> you want with it.

Thanks for the info & code. I was leery of using the output_to_core method, as
the module author seems to feel that writing out temp files is just about as
fast & less likely to consume all available memory - guess we need to put  the
$parser->parse code in an eval block.  And we're still decoding attachments,
which I would like to avoid. Ideally, it would be nice to have this method:
$parser->parse_headers_only, which doesn't do anything with attachments.

GK



Mon, 08 Mar 2004 02:28:15 GMT  
 MIME::Tools - Getting All MIME Header Info for a Message



: >
: > > I'm interested in getting all MIME part information for e-mail messages.
: > > I'm currently using MIME::Parser->parse(\*MSG), but that method
: > > extracts/decodes all attachments to disk, which can take a fair amount
: > > of time. Is there a method/methods I'm overlooking that can simply get
: > > *all* of  the MIME information without doing the attachment decoding?
: > > (I'm stressing "all", as MIME::Head can get the information for a given
: > > header, but seeking out *all* headers seems like a more significant
: > > undertaking (which I won't do if someone else has already done it).
: >
: > You can tell MIME::Parser how to handle the parsed data. As default it
: > puts them somewhere on disk. Hence, before parsing, call
: >
: >         $parser->output_to_core(1);
: >
: > As for iterating over all MIME-parts (and the headers thereof), use the
: > parts or parts_DFS method.
: >
: > my $parser  = new MIME::Parser; $parser->output_to_core(1);
: > my $top_ent = $parser->parse(\*STREAM);


: >

: > you want with it.
: >

: Thanks for the info & code. I was leery of using the output_to_core method, as
: the module author seems to feel that writing out temp files is just about as
: fast & less likely to consume all available memory - guess we need to put  the
: $parser->parse code in an eval block.  And we're still decoding attachments,
: which I would like to avoid. Ideally, it would be nice to have this method:
: $parser->parse_headers_only, which doesn't do anything with attachments.

Since the MIME modules use OOP calling, perhaps you can override one of
the methods so that the decoding just tosses the data away.

IN fact this could be used to ignore the data without dealing with flags
like output_to_core, simply override the method that writes the data with
your do-nothing method that tosses it away.

(I have no idea which if any method you would need to override.)



Mon, 08 Mar 2004 06:54:56 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Problem with MIME::Lite and MIME-tools

2. MIME-Tools - MIME::Entity - extra newline problem

3. MIME::Tools decoding of a MIME::Entity

4. problems with MIME::Lite and MIME-tools

5. Problem with MIME::Lite and MIME-tools

6. Announce: mime+.pl, MIME multipart message assembler.

7. MIME-tools/Mail-tools incompatible?

8. MIME::Parse and MIME::Entity

9. Prob w/ MIME::Body, MIME::Parser

10. Please help with MIME::Parser and MIME::Entity

11. ANNOUNCE: MIME:: modules for parsing MIME streams

12. MIME-tools help

 

 
Powered by phpBB® Forum Software