I'm using Mail::Internet module, which will basically filter through email content and extract the body of the message
my perl script to extract the body of the email
HTML Code:
#!/usr/bin/perl -w
use Mail::Internet;
@lines = <STDIN>;
$mi_obj = new Mail::Internet([@lines]);
$mi_obj->print_body(\*STDOUT);
my email.txt file
HTML Code:
From rsmith@test.com Fri Feb 24 17:41:32 2012
Return-Path: <rsmith@test.com>
X-Original-To: datamgr@tordata1.test.com
Delivered-To: datamgr@tordata1.test.com
Received: from fssmtp1.test.com (fssmtp1.test.com [10.10.10.40])
by tordata1.test.com (Postfix) with ESMTP id 214A2E704D4
for <datamgr@tordata1.test.com>; Fri, 24 Feb 2012 17:41:32 -0500 (EST)
Received: from LT1805 (unknown [172.20.51.20])
by fssmtp1.test.com (Postfix) with ESMTP
id CC1BE1C4356; Fri, 24 Feb 2012 17:41:31 -0500 (EST)
MIME-Version: 1.0
From: rsmith@test.com
To: datamgr@tordata1.test.com
Cc: knorwood@test.com
Date: 24 Feb 2012 17:41:31 -0500
Subject: New Number Test
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Message-Id: <20120224224131.CC1BE1C4356@fssmtp1.test.com>
2012124541=0D=0A2012124542=0D=0A2012124543=0D=0A2012124544=0D=0A2=
013810008=0D=0A2013810009=0D=0A2013810011=0D=0A2013810012=0D=0A20=
13810013=0D=0A2013810014=0D=0A2013810015=0D=0A2014732160=0D=0A201=
4732161=0D=0A2015306904=0D=0A2015306905=0D=0A2016083923=0D=0A2016=
083924
when running the script on the command line
HTML Code:
perl perl_script.pl < email.txt
I get the following output
HTML Code:
2012124541=0D=0A2012124542=0D=0A2012124543=0D=0A2012124544=0D=0A2=
013810008=0D=0A2013810009=0D=0A2013810011=0D=0A2013810012=0D=0A20=
13810013=0D=0A2013810014=0D=0A2013810015=0D=0A2014732160=0D=0A201=
4732161=0D=0A2015306904=0D=0A2015306905=0D=0A2016083923=0D=0A2016=
083924
which is perfectly file, however I only want to see the numbers before the first = sign on each line.
HTML Code:
2012124541
013810008
13810013
4732161
how can I achieve that???
your help is highly appreciated