[thelist] Bash script to handle email
Seamus
seamuscawley at gmail.com
Sat Nov 13 08:13:50 CST 2004
Hey all,
I'm using this script to handle email
#! /usr/bin/php -q
<?
// read from stdin
$lines = file("/dev/stdin");
// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;
$count=count($lines);
for ($i=0; $i<$count; $i++) {
if ($splittingheaders) {
// this is a header
$headers .= $lines[$i]."\n";
// look out for special headers
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from = $matches[1];
}
} else {
// not a header, but message
$message .= $lines[$i]."\n";
}
if (trim($lines[$i])=="") {
// empty line, header section has ended
$splittingheaders = false;
}
}
mail('seamuscawley at gmail.com',$subject,$message);
?>
but it doesn't work.
Does any one have, or know where I would fing a shell script to do the same.
Also what exactly should I have in my .forward file to forward all
mail to this script
--
Holiday Apartments in Ireland < http://holidayapartment.f-m.fm >
Coding World < http://codingworld.proboards27.com >
More information about the thelist
mailing list