Board index » cppbuilder » Help parsing an email header

Help parsing an email header


2005-02-23 10:04:57 AM
cppbuilder36
Can someone help me with this? I am trying to parse and email
header for all the "Received:" fields, then i have to extract the
ip addresses from them. But for now does anyone have a
parser thats written already, or provide me with a sample
please. Here is a header that i grabbed.
------------------------ Snip ---------------------------------------
X-YahooFilteredBulk: 219.251.123.139
Authentication-Results: mta817.mail.scd.yahoo.com
from=redwhitearmy.com; domainkeys=neutral (no sig)
X-Originating-IP: [219.251.123.139]
Return-Path: < XXXX@XXXXX.COM >
Received: from 219.251.123.139 (EHLO yipvma.prodigy.net)
(207.115.63.28)
by mta817.mail.scd.yahoo.com with SMTP; Tue, 22 Feb 2005
09:57:55 -0800
X-Header-Overseas: Mail.from.Overseas.source.219.251.123.139
X-Header-NoReverseIP: IP.name.lookup.failed[219.251.123.139]
X-Originating-IP: [219.251.123.139]
Received: from K2DFTQXW6K0YXC7 ([219.251.123.139])
by yipvma.prodigy.net (8.12.10 083104/8.12.10) with SMTP id
j1MHvO6T421874;
Tue, 22 Feb 2005 12:57:53 -0500
Subject: [Bulk] Confirmation Link
Message-ID: <%CUSTOM_MESSAGEID>
From: "Loren" < XXXX@XXXXX.COM >
To: "Loren" < XXXX@XXXXX.COM >
Date: Tue, 22 Feb 2005 21:49:11 +0400
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="--Part.TRYDkg6Y0.aUUrxRDlFM2"
------------------------ Snip ---------------------------------------
I only want these two fields back from the entire header:
Received: from 219.251.123.139 (EHLO yipvma.prodigy.net)
(207.115.63.28)
Received: from K2DFTQXW6K0YXC7 ([219.251.123.139])
Then i have to get the two ipaddy here
219.251.123.139
219.251.123.139
TIA anyone.
 
 

Re:Help parsing an email header

Josh Jameson wrote:
Quote
Can someone help me with this? I am trying to parse and email
header for all the "Received:" fields, then i have to extract the
ip addresses from them. But for now does anyone have a
parser thats written already, or provide me with a sample
please. Here is a header that i grabbed.

------------------------ Snip ---------------------------------------
X-YahooFilteredBulk: 219.251.123.139
Authentication-Results: mta817.mail.scd.yahoo.com
from=redwhitearmy.com; domainkeys=neutral (no sig)
X-Originating-IP: [219.251.123.139]
Return-Path: < XXXX@XXXXX.COM >
Received: from 219.251.123.139 (EHLO yipvma.prodigy.net)
(207.115.63.28)
by mta817.mail.scd.yahoo.com with SMTP; Tue, 22 Feb 2005
09:57:55 -0800
X-Header-Overseas: Mail.from.Overseas.source.219.251.123.139
X-Header-NoReverseIP: IP.name.lookup.failed[219.251.123.139]
X-Originating-IP: [219.251.123.139]
Received: from K2DFTQXW6K0YXC7 ([219.251.123.139])
by yipvma.prodigy.net (8.12.10 083104/8.12.10) with SMTP id
j1MHvO6T421874;
Tue, 22 Feb 2005 12:57:53 -0500
Subject: [Bulk] Confirmation Link
Message-ID: <%CUSTOM_MESSAGEID>
From: "Loren" < XXXX@XXXXX.COM >
To: "Loren" < XXXX@XXXXX.COM >
Date: Tue, 22 Feb 2005 21:49:11 +0400
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="--Part.TRYDkg6Y0.aUUrxRDlFM2"
------------------------ Snip ---------------------------------------

I only want these two fields back from the entire header:

Received: from 219.251.123.139 (EHLO yipvma.prodigy.net)
(207.115.63.28)
Received: from K2DFTQXW6K0YXC7 ([219.251.123.139])

Then i have to get the two ipaddy here
219.251.123.139
219.251.123.139

TIA anyone.
Use a TStringList, it will "cut" the header into seperate lines and then you
can serch for the line you want.