Bob Berman <rjberman(_at_)mindspring(_dot_)com> writes:
I am trying to extract fields using formail. I am using the procmail 3.13.1
distribution. For example, I'd like to extract the Subject: field from the
following message, but as long as I have the "Received" lines in there, I
can't extract it. If I delete from the first Received line to the line before
the Message-ID, it works fine. How do I get it to work? Most of my mail comes
with Received headers.
...
From test(_at_)test(_dot_)com Wed May 12 23:46:45 1999
Received: from localhost (rberman(_at_)boomer(_dot_)mindspring(_dot_)com
[127.0.0.1])
by boomer.mindspring.com (8.9.1/8.9.3) with ESMTP id XAA09011
for <rberman(_at_)localhost>; Wed, 12 May 1999 23:46:44 -0400
Received: from pop.mindspring.com
by localhost with POP3 (fetchmail-4.7.7)
for rberman(_at_)localhost (single-drop); Wed, 12 May 1999 23:46:44 -0400 (EDT)
Received: from hopper.otherco.com ([207.204.138.66])
...
As displayed above, this message has been corrupted. In particular,
the Received: headers have been wrapped without indenting the
continuing lines. formail assumes that it has hit the end of the
message header when it sees a line that doesn't fit the message header
format, and so formail doesn't see a Subject: header, because it's in
the body.
The solution is to correctly indent the second and following line of
each continued header with one whitespace character (space or tab).
Structured headers (such as Received:, address headers, and
Content-Type:) can be indented with more than one, as unquoted
whitespace is not significant in them except as a token separator.
So:
From test(_at_)test(_dot_)com Wed May 12 23:46:45 1999
Received: from localhost (rberman(_at_)boomer(_dot_)mindspring(_dot_)com
[127.0.0.1])
by boomer.mindspring.com (8.9.1/8.9.3) with ESMTP id XAA09011
for <rberman(_at_)localhost>; Wed, 12 May 1999 23:46:44 -0400
Received: from pop.mindspring.com
by localhost with POP3 (fetchmail-4.7.7)
for rberman(_at_)localhost (single-drop); Wed, 12 May 1999 23:46:44 -0400
(EDT)
Received: from hopper.otherco.com ([207.204.138.66])
...
As for your incoming mail, _every_ message you receive should have at
least one Received: header. If they aren't continued correctly, then
your system's MTA is broken.
Philip Guenther