So, what I need to do is process mail in mbox format:
1) Get a message
2) Do stuff to the body
3) Print the mail back, preserving attachments
I've tried this:
#!/usr/bin/perl
use Mail::Mbox::MessageParser;
use Email::MIME;
use Encode;
my $infile = shift @ARGV;
Mail::Mbox::MessageParser::SETUP_CACHE(
{
'file_name' => 'mbox.cache'
});
my $folder_reader = new Mail::Mbox::MessageParser({
'file_name' => $infile,
'enable_grep' => 1,
});
die $folder_reader unless ref $folder_reader;
# This is the main loop. It's executed once for each email
while(!$folder_reader->end_of_file()){
my $rawemail = $folder_reader->read_next_email();
my $email = Email::MIME->new($rawemail);
$email->body_set("New Body Text");
print $email->as_string
but it seems to ignore the new body..
If I include EMail::MIME:Modifier, the text "New Body Text" is printed, but no attachments....
How do I do this?
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.