[plug] Mail Filtering

Jason Bainbridge JaseOne at myrealbox.com
Wed Aug 28 16:11:41 WST 2002


I'm taking a stab in the dark here mainly to see if my Perl skills are still there after several years of no use, so it might be better waiting for a more expert response but anyway:

-------------------------------------
#!/usr/bin/perl

#read the _whole_ file from stdin into $_;
undef $/;
$_=<STDIN>;

#get rid of the email headers
# headers are seperated from the body of the message by a blank line.
s/^.*?\n\n//gs;

open(DATA, ">public_html/registered_names.txt") or
         die "failed to open public_html/registered_names.txt: $!\n";
print DATA $_;
close(DATA);
#replace newline chars with html <BR>
$_ = s/\n/<BR>/g;
#write the flash file
open(DATA, ">public_html/registered_names_flash.txt") or
         die "failed to open public_html/registered_names_flash.txt: $!\n";
print DATA $_;
close(DATA);


--------

Regards,
Jason
*eagerly awaiting feedback*

-----Original Message-----
From: I am the LinuxAlien <linuxalien at optusnet.com.au>
To: plug at plug.linux.org.au
Date: Wed, 28 Aug 2002 15:26:19 +0800
Subject: [plug] Mail Filtering

Ok, some time back I asked for help getting an  email to replace a file in 
my public-html folder. The solution is below.
-------------------------------------
#!/usr/bin/perl

#read the _whole_ file from stdin into $_;
undef $/;
$_=<STDIN>;

#get rid of the email headers
# headers are seperated from the body of the message by a blank line.
s/^.*?\n\n//gs;

open(DATA, ">public_html/registered_names.txt") or
         die "failed to open public_html/registered_names.txt: $!\n";
print DATA $_;
close(DATA);
--------

Then in ~/.procmailrc do something like:
---
:0
* ^From:.*callen at corpus.wa.edu.au
| /path/to/script
---
-------------------------------------------------------
What i now need is for it to work differently, i need it to split into 2 
different files.
The email will look something like this
---------------------
Matthew Whocare
Sarah Wile
Katlen Minkle
Mill Nasf
---------------------
The that i need are below
---------------------
registered.txt
----
Matthew Whocare
Sarah Wile
Katlen Minkle
Mill Nasf
---------------------
registered_flash.txt
----
names=Matthew Whocare<br>Sarah Wile<br>Katlen Minkle<br>Mill Nasf
----
I don't no how to script other than simple stuff.
Thanks,
Tim


LinuxAlien
Riverton, Perth, WA

Australian Linux Technical Conference, Perth 2003 http://linux.conf.au




More information about the plug mailing list