in reply to Mimetools
I will now assume that your mail is sitting in a text file named incoming.
#!/usr/bin/perl -w use strict; use MIME::Parser; my $parser=new MIME::Parser; $parser->output_dir("mime"); open FILE, "incoming" ||die "could not open\n"; my $email=$parser->read(\*FILE)||die "could not parse\n"; close FILE; ## Now $email is a MIME::Entity. if (!$email->parts) { my $bodyh=$email->bodyhandle; my $IO = $body->open("r") || die "open body: $!"; open OUTFILE, ">body"; while(defined($_ = $IO->getline)) { print OUTFILE; } $IO->close; close OUTFILE; } else { print "This is a multipart MIME message, and I need to do more work +to be able to read it.\n"; } $email->purge;
Hopefully that gets you started... No guarantees against typos in the code...
|
|---|