If you have slurp your headers into a scalar, it's easy to chop it up into an array with multiline headers correctly stitched up together:

my $header = <<'HEADER'; Return-Path: <NITAIGOURANGA@AOL.COM> X-Original-To: grinder@example.com Delivered-To: grinder@example.com Received: from RX504Second (ACBC197E.ipt.aol.com [172.188.25.126]) by example.com (Postfix) with SMTP id C5960A94C for <grinder@example.com>; Mon, 30 Jun 2003 13:18:36 +0200 (CE +ST) From: "GOURANGA" <NITAIGOURANGA@AOL.COM> HEADER my @header = split /\n(?!\s+)/, $header;

You might want to post-process each element to fold whitespace as well. A module will probably do a better job, but I find tr/\n\t / /s is usually good enough for my needs.

Once you have your headers, I would suggest looking at the Return-Path: header, which holds the envelope sender of the message. I would also suggest you take a look at the Received: headers as well. These two items are very revealing when it comes to dealing with spew. The To: and From: headers are nearly always forged, or at least irrelevant, in spammers' messages.

_____________________________________________
Come to YAPC::Europe 2003 in Paris, 23-25 July 2003.


In reply to Re: Finding e-mail headers by grinder
in thread Finding e-mail headers by AssFace

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.