Description
- A mail consists of a mail header containing header fields and optionally
a mail body.
- The header and the body of a mail is separated by an empty line.
- Each header field may consists of more than one line.
In this case, the second and the following lines of that field
begin with whitespace characters.
According to Section 2.2.3 of RFC 2822,
you may insert CRLF(carriage return and newline/linefeed character) before
any whitespace character in a header field to split it into several lines.
This is called `folding'.
- We want to add an separator `------------' after every header field.
|
| Raw Input
|
| Desired Output
| Return-Path: <root@hq>
Received: from main.rt.com.tw (mail.hq [10.11.1.1])
by smb.knit.plant (Postfix) with ESMTP id D8D8F2DC24
for <steven@plant>; Thu, 6 Aug 2009 08:10:06 +0800 (CST)
Received: by main.rt.com.tw (Postfix, from userid 0)
id C212627F68; Thu, 6 Aug 2009 08:10:06 +0800 (CST)
X-Original-To: mbackup@mbackup.hq
Delivered-To: mbackup@mbackup.hq
Received: from smb.knit.plant (smb.knit.plant [10.12.1.22])
by main.rt.com.tw (Postfix) with ESMTP id 8808727F58;
Thu, 6 Aug 2009 08:07:18 +0800 (CST)
Received: from [10.3.1.70] (unknown [10.13.1.70])
by smb.knit.plant (Postfix) with ESMTP id 4B5912DC28;
Thu, 6 Aug 2009 08:07:18 +0800 (CST)
Message-ID: <4A7A1E6D.8080702@rt.com.tw>
Date: Thu, 06 Aug 2009 08:06:05 +0800
From: Pon <pu@rt.com.tw>
To: Celine <celine_chang@kabin>
Subject: test mail....
This is a test mail....
Mail body line 2...
Mail body line 3....
|
| Return-Path: <root@hq>
---------------
Received: from main.rt.com.tw (mail.hq [10.11.1.1])
by smb.knit.plant (Postfix) with ESMTP id D8D8F2DC24
for <steven@plant>; Thu, 6 Aug 2009 08:10:06 +0800 (CST)
---------------
Received: by main.rt.com.tw (Postfix, from userid 0)
id C212627F68; Thu, 6 Aug 2009 08:10:06 +0800 (CST)
---------------
X-Original-To: mbackup@mbackup.hq
---------------
Delivered-To: mbackup@mbackup.hq
---------------
Received: from smb.knit.plant (smb.knit.plant [10.12.1.22])
by main.rt.com.tw (Postfix) with ESMTP id 8808727F58;
Thu, 6 Aug 2009 08:07:18 +0800 (CST)
---------------
Received: from [10.3.1.70] (unknown [10.13.1.70])
by smb.knit.plant (Postfix) with ESMTP id 4B5912DC28;
Thu, 6 Aug 2009 08:07:18 +0800 (CST)
---------------
Message-ID: <4A7A1E6D.8080702@rt.com.tw>
---------------
Date: Thu, 06 Aug 2009 08:06:05 +0800
---------------
From: Pon <pu@rt.com.tw>
---------------
To: Celine <celine_chang@kabin>
---------------
Subject: test mail....
---------------
This is a test mail....
Mail body line 2...
Mail body line 3....
|
|
Script and Comments
Script1 [ 1] :loop
[ 2] N
[ 3] /\n[ ]+[^\n]*$/b loop
[ 4] h
[ 5] s/^.*\n//
[ 6] x
[ 7] s/\n[^\n]*$/\n---------------/p
[ 8] g
[ 9] /^$/!b loop
[10] :loop1
[11] n
[12] b loop1
| |