[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: maildata statistics



On Fri, Mar 28, 2003 at 02:29:50AM +0900, Tsuyoshi Takada wrote:
> There is a large mail data file "1.txt". Each mail is separated by the 
> strings "\n\.\n". Mail header and mail body is separated by "\n\n".
> 
> For example, this mail data format is the following.
> -----------------------
> Return-Path: <something>
> Received: <something>
> <something>
> <something>
> To: <something>
> From: foo@example.com
> 
> Hello!
> World!
> .
> Return-Path: <something>
> ...
> -----------------------
> 
> I want to output all the "To:" fields in the mail which contains
> "example.com" in the "From:" field.
> -------------
> To: hoge@hoge.com
> To: foo@example.net
> ...
> ------------
> 
> What language/software/environment do you use to develop this program?

With the exception of the slightly awkward "\n.\n" separator, grepmail?
If your input is in fact batched SMTP (so . at the beginning of a line
is escaped by prepending an additional .), and if it isn't it probably
should be, then you can convert that to mbox pretty trivially with perl
and pipe the result to grepmail.

That's one approach, anyway. I'd certainly use perl for this.

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]



Reply to: