procmail
[Top] [All Lists]

Re: mail processing

1996-01-08 11:16:20
I see a two part solution for this:

Part 1:  A procmmail recipe that recognizes contest email by a token
in the subject field, for instance:

:0
* ^Subject:.*Contest Entry
| /usr/contest/store_entry

Part 2:  The store_entry script

This would be an awk or perl script that reads the email message and
outputs the needed data to the specified file:

#!/usr/local/bin/perl

# Output file
$output="/usr/contest/contest_data";

open(OUT, >>$output) || dir "unable to open output file, !$\n";

# skip header
while (<>)
{
    last if m/^$/;
}

while (<>)
{
    ($key,$val) = split;
    $fields{$key} = $val;
}

printf OUT "%s %s %s",
       $fields{'TEAM'},
       $fields{'PRICE'},
       $fields{'PASSWORD'};

close(OUT);

exit;

This is an extremeley barebones version.

--[Lance]

<Prev in Thread] Current Thread [Next in Thread>