[ale] Easy way to cut body of email in perl

Allan Neal allanneal at comcast.net
Wed Jan 4 17:34:38 EST 2006


You could pipe it through formail first.  From the man page on formail:

 To extract the body from a message:
               formail -I ""

Allan

On Wed, Jan 04, 2006 at 05:08:35PM -0500, Christopher Fowler wrote:
> I'm using procmail to pass email via STDOUT to a program that is
> supposed to do various things based on what is in the email.  I need a
> way in perl to separate the headers from the body.  Attached is a piece
> of my log file that shows email that the system received.
> 
> ---------------------------------------------------------------------------------
> 01-04 16:26:54 From tomcat  Wed Jan  4 16:26:54 2006
> 01-04 16:26:54 Return-Path: <cfowler at outpostsentinel.com>
> 01-04 16:26:54 Received: from pop.outpostsentinel.com [207.217.120.139]
> 01-04 16:26:54  by localhost with POP3 (fetchmail-6.2.5)
> 01-04 16:26:54  for tomcat at localhost (single-drop); Wed, 04 Jan 2006
> 16:26:54 -0500 (EST)
> 01-04 16:26:54 Received: from www.linuxiceberg.com ([66.23.224.81])
> 01-04 16:26:54  by bluebird.mail.pas.earthlink.net (EarthLink Mail
> Service) with ESMTP id 1eUg7Y55L3NZFmn0
> 01-04 16:26:54  for <sam02 at outpostsentinel.com>; Wed, 4 Jan 2006
> 13:25:02 -0800 (PST)
> 01-04 16:26:54 Received: from [192.168.1.115] ([192.168.1.115])
> 01-04 16:26:54  by www.linuxiceberg.com (8.11.6/8.11.6) with ESMTP id
> k04LP3e01295
> 01-04 16:26:54  for <sam02 at outpostsentinel.com>; Wed, 4 Jan 2006
> 16:25:03 -0500
> 01-04 16:26:54 Subject: Re: New Alarm: 3
> 01-04 16:26:54 From: Christopher Fowler <cfowler at outpostsentinel.com>
> 01-04 16:26:54 To: Chris Fowler <sam02 at outpostsentinel.com>
> 01-04 16:26:54 In-Reply-To: <200601042114.k04LEeMp015227 at sam-
> demo.opsup.com>
> 01-04 16:26:54 References: <200601042114.k04LEeMp015227 at sam-
> demo.opsup.com>
> 01-04 16:26:54 Content-Type: text/plain
> 01-04 16:26:54 Date: Wed, 04 Jan 2006 16:25:01 -0500
> 01-04 16:26:54 Message-Id:
> <1136409901.14670.162.camel at shuttle.linxdev.com>
> 01-04 16:26:54 Mime-Version: 1.0
> 01-04 16:26:54 X-Mailer: Evolution 2.0.4 (2.0.4-7)
> 01-04 16:26:54 Content-Transfer-Encoding: 7bit
> 01-04 16:26:54
> 01-04 16:26:54 BUFFER
> 01-04 16:26:54
> 01-04 16:26:54 On Wed, 2006-01-04 at 16:14 -0500, Chris Fowler wrote:
> 01-04 16:26:54 > Alarm: 3.
> 01-04 16:26:54 > ID            = 3
> 01-04 16:26:54 > Alarm Match   = Interface FastEthernet0/8, changed
> state to down
> 01-04 16:26:54 > Description   = Interface down on Cisco Switch
> 01-04 16:26:54 > Device        = Cisco2900-XL
> 01-04 16:26:54 > Location      = OutPost Alpharetta
> 01-04 16:26:54 > Time          = Wed Jan  4 16:12:59 2006
> 01-04 16:26:54 > MsgID         =
> NcdDbKQnYQSSzgmPrTQmfKfbGpyWdzHv.1136409280
> ---------------------------------------------------------------------------------
> 
> Should I consider everything after "Content-Transfer-Encoding" to be the
> body?
> 
> 
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale

-- 
 ________________________________________
/\                                       \
\_|   I count him braver who overcomes   |
  |   his desires than he who conquers   |
  | his enemies; for the hardest victory |
  |      is the victory over self.       |
  |             - Aristotle              |
  |   ___________________________________|_
   \_/_____________________________________/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available




More information about the Ale mailing list