Re: deciphering emails in PERL
From: Bob Walton (see_at_sig.invalid)
Date: 10/22/04
- Next message: daniel kaplan: "help with net pop3"
- Previous message: Gunnar Hjalmarsson: "Re: date time manipulation perl"
- In reply to: daniel kaplan: "deciphering emails in PERL"
- Next in thread: daniel kaplan: "Re: deciphering emails in PERL"
- Reply: daniel kaplan: "Re: deciphering emails in PERL"
- Reply: daniel kaplan: "Re: deciphering emails in PERL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 21 Oct 2004 22:04:28 -0400
daniel kaplan wrote:
> i am using net::pop3 to read from my email server, but am having some
> difficulties...
>
> for instance i can easily find the FROM and TO and SUBJECT
>
> but deiphering where the BODY of the message itself is kind of hard....so
> manny headers, and they change depending on the format (HTML vs. NON) and
> the sending app...OE, AOL, etc
>
> i have to think, with the vast exapnse of lib. i see out there for PERL,
> someone has written something? no?
Did you miss the FAQ "How do I parse a mail header"? (in perlfaq9). It
points you to some stuff on CPAN, which is an excellent place to look
for pre-written code to do common tasks in Perl.
The body of a mail message starts after the first null line. You should
be able separate the header from the body with something like:
my $header;my $body;
($header,$body)=split "\n\n",$msg,2;
This assumes you have one message in $msg -- mail messages in a standard
mail file each start with the characters "From " starting in column 1,
without the quotes but including the space (not to be confused with the
"From:" header line). Text lines starting with those characters is
prohibited in messages, and is commonly handled by replacing "From " in
the message body with ">From " if it occurs in column 1.
HTH.
-- Bob Walton Email: http://bwalton.com/cgi-bin/emailbob.pl
- Next message: daniel kaplan: "help with net pop3"
- Previous message: Gunnar Hjalmarsson: "Re: date time manipulation perl"
- In reply to: daniel kaplan: "deciphering emails in PERL"
- Next in thread: daniel kaplan: "Re: deciphering emails in PERL"
- Reply: daniel kaplan: "Re: deciphering emails in PERL"
- Reply: daniel kaplan: "Re: deciphering emails in PERL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|