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

I can't say I've used that module, (and it looks to me as if it's more for building mail messages for sending, rather than parsing incoming messages, which is what I assume you're trying to do) but a couple of things spring to mind

BTW, I'm not saying that it is, but you probably don't want to include real email addresses in examples on PM

Replies are listed 'Best First'.
Re: Re: Re: Re: Parse a Mail
by Spida (Acolyte) on Oct 08, 2002 at 09:16 UTC
    Mail Message CAN handle STDIN -
    at least http://perl.overmeer.net/mailbox/html/Mail/Message/Construct.html#SYNOPSIS says so
    The error got away after I deleted the first line of the message. Please don't ask me why.

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

        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();