AW: A parsing problem an email header...

"Luft, Markus" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.mail-box
Message-ID <78CB79D4F16FFD4C8D7D1E557012AF28043AC161@derum202>
Hi Bill,

I'm also new to Mail::Box :-)

> I got this error message:
> "WARNING: Illegal character in field name From"

The email you piped to your script is not a message but it is in mbox
format. In this case you should use another example to read your email.
I put everything into a file and ran this attached script.

The illegal character warning is a result of a - for an email message -
malformed from line which is correct for mbox format.

Regards
   Markus


#!/usr/bin/perl

use warnings;
use strict;
use Mail::Box::Manager;

#
# Get the command line arguments.
#

die "Usage: $0 folderfile\n"
    unless @ARGV==1;

my $filename = shift @ARGV;

#
# Open the folder
#

my $mgr    = Mail::Box::Manager->new;

my $folder = $mgr->open
   ( $filename
   , extract => 'LAZY'   # never take the body unless needed
   );                    #  which saves memory and time.

die "Cannot open $filename: $!\n"
    unless defined $folder;

#
# List all messages in this folder.
#

my @messages = $folder->messages;
print "Mail folder $filename contains ", scalar @messages, " messages:\n";

my $counter  = 1;
foreach my $msg (@messages)
{
  my $head = $msg->head;
  my $body = $msg->body;

  print $msg->subject,"\n";

  print $body,"\n";
}

#
# Finish
#

$folder->close;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.