luckypower has asked for the wisdom of the Perl Monks concerning the following question:
any suggestion ...???my $oldmail = "mailfile.eml"; my $parser = new MIME::Parser; my $entity = new MIME::Entity; $entity = $parser->parse_open($oldmail); $newmail = create_mail($entity); open(NEWMAIL, ">newmail.eml"); print NEWMAIL, $newmail->as_string; sub create_mail { my $mail = shift; my $encodetype = $mail->head->mime_encoding; if ($encodetype eq "base64") { my $body = $mail->bodyhandle; my $fname = $mail->head->recommended_filename; open(BODY, ">$fname") or die "Cant..."; print BODY $body->as_string; close(BODY); my $contype = $mail->head->get("Content-Type"); my $contranencode = $mail->head->get("Content-Transfer-Encodin +g"); my $condispo = $mail->head->get("Content-Disposition"); my $attachment = new MIME::Entity->build( Path => $fname, Type => $contype, Encoding => "base64", Filename => $fname, Disposition => $condispo); return $attachment; } elsif ($mail->parts > 0) { my $ent = new MIME::Entity; my $head = "mailhead.hdr"; open(HEAD, ">$head") or return printerror(); $mail->head->print(\*HEAD); close(HEAD); $ent->head(MIME::Head->from_file($head)); foreach my $part ($mail->parts) { my $subent = compress_mail($part); $ent->add_part($subent); } unlink $head; return $ent; } return $mail; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem with size of reconstructed email
by ikegami (Patriarch) on Oct 08, 2008 at 07:48 UTC | |
by luckypower (Beadle) on Oct 20, 2008 at 12:08 UTC | |
|
Re: problem with size of reconstructed email
by Anonymous Monk on Oct 08, 2008 at 07:20 UTC |