note
RuneK
Hi again,
Thanks for the answer but I cannot seem to get your part with the mbox to work.
<br>
I'm using the .procmailrc with the following statement:
<br><br>
:0
| /tmp/mailparser.pl> /tmp/test.log
<br><br>
So I'm parsing the mail directly to the script which should read it through STDIN.
<br>
I changed the print (to,from,subject,body) to print to a file instead because that is what I need, but the file is empty. The script now looks like this:
<code>
#!/usr/bin/perl -w
use strict;
use warnings;
use Mail::MboxParser;
my $mbox= \*STDIN;
my $mb = Mail::MboxParser->new($mbox);
open (MSG,">mailmessage");
for my $msg ($mb->get_messages) {
my $to = $msg->header->{to};
my $from = $msg->header->{from};
my $cc = $msg->header->{cc} || " ",
my $subject = $msg->header->{subject} || '<No Subject:>',
my $body = $msg->body($msg->find_body,0);
my $body_str = $body->as_string || '<No message text>';
print MSG "To: $to\n",
"From: $from\n",
"Cc: $cc\n",
"Subject: $subject\n",
"Message Text: $body_str\n";
print MSG "~" x 77, "\n\n";
close MSG;
}
</code>
<br>
The file is created so it's not a permission problem but it is empty. The MboxParser.pm is just installed.
<br>
Any ideas?
<br>
Thanks,
Rune
194574
194574