Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Carving up MIME email on STDIN

by markov (Scribe)
on Dec 03, 2003 at 19:31 UTC ( #311984=note: print w/replies, xml ) Need Help??

in reply to Carving up MIME email on STDIN

Yes, there is little info in the docs -- and I have to maintain that MailTools code :-( -- Anyway, after playing around with it, I decided that the structure chosen is not sufficient for the current complex messages. Have you thought of multi-level multiparts? Anyway: there came MailBox

Example to show that it works easy (although installation has too many dependencies, I know):

 use File::Temp;
 my $dir = tempdir; mkdir $dir or die;
 use Mail::Message;
 my $msg = Mail::Message->read(\*STDIN);
 foreach my $part ($msg->parts('RECURSE'))
 {  next if $part->isBinary;
    my $fn  = $message->body->dispositionFilename($dir);

    $message->decoded->write(filename => $fn)
        or die "Couldn't write to $fn: $!\n";

See Mail::Box in HTML. Have a look at rebuild(), which may be able to do for you what you had planned. Just an alternative to MIME::* and MailTools to keep in mind.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://311984]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2018-05-26 03:27 GMT
Find Nodes?
    Voting Booth?