in reply to Re: Re: Re: Re: Parse a Mail
in thread Parse a Mail

Is there any chance of you posting the message text & headers - with suitably munged addresses?

Replies are listed 'Best First'.
Re: Re: Parse a Mail
by Spida (Acolyte) on Oct 09, 2002 at 12:49 UTC
    Header was:
    From example.user@t-online.de Wed Oct 09 10:21:57 2002
    Return-path: <example.user@t-online.de>
    Envelope-to: user@test.example.com Delivery-date: Wed, 09 Oct 2002 10:21:57 +0200 Received: ===hidden===
    To: user@example.com
    Subject: Re: Your mail
    From: example.user@t-online.de
    Date: Wed, 09 Oct 2002 10:23:52 +0200 (CEST)
    Message-ID: <23758295.8767v7i6u675@webmail.t-online.de>
    In-Reply-To: <E17yzpu-00060u-00@test>
    References: <E17yzpu-00060u-00@test>
    X-Mailer: T-Online WebMail 2.05
    X-Complaints-To: abuse#webmail@t-online.com
    MIME-Version: 1.0
    Content-Type: text/plain; charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    X-Sender: ===hidden===@t-dialin.net
    Got it running by my self.
    The first line was the problem.
    my $firstline=1; while (<STDIN>) { if (!($firstline)) { push(@mail, $_); } $firstline=0; } $msg = Mail::Message->read(\@mail); $sender = $msg->sender; $replyto = Mail::Address->parse($msg->head->get('Reply-To')); if ($replyto) { $sender =$replyto; } $subject = $msg->subject; if($msg->isMultipart) { $summary = $msg->body->preamble; $summary .= "Number of attachments: ".scalar $msg->body->parts +('ACTIVE')."\n\n"; my $number =0; foreach my $part ($msg->body->parts) { $number++; $summary .= "======== Attachment ".$number." Type: ".$ +part->get('Content-Type')." =========\n"; # Attachment handling if ($part->get('Content-Type') eq "text/plain" ) { $summary .= $part->decoded."\n"; } $summary .= "========================================= +=================\n\n"; } $summary .= $msg->body->epilogue; } else { $summary = $msg->decoded; } $summary.="\nMail from: ".$sender->format();