Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2016-10-21 09:21 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (288 votes). Check out past polls.