heh! I'm doing almost exactly the same thing. I tested this and it works for me:
use strict;
use warnings;
use MIME::Parser;
## my alias line:
## menu: \menu, "|/usr/perl/mime.parser.p"
## '\menu' keeps a copy in the inbox for account menu
my $parser = new MIME::Parser;
## The secret here is that the directory must pre-exist
## and must be writable by the daemon that runs the
## parsing script. In my case user=daemon group=other
## I determined the correct values by initially making
## /tmp/mimemail using permissions 777.
$parser->output_dir("/tmp/mimemail");
my $entity = $parser->read(\*STDIN)
or die "\n\nCouldn't parse MIME stream\n\n";
For actual use I'd create the directory internally from the program and then remove it when finished. You'll also want to come up with some dynamic means of choosing the directory name since you don't want to try and delete the directory while another instance of the program is trying to write to it.
All you have to do now is figure out how to scarf the other portions of the original message using MIME::Parser before resending with MIME::Lite.
--Jim
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|