Email pipe to php script
I have the forwarder set up properly in cpanel as well as the permissions to the script set properly. I even can pull out the from email address, and subject. The part that I am having an issue with is how to pull out the message without any other BS besides the actual message text/HTML. Below is the code I am using... If someone can guide me in the right direction that would be greatly appreciated.
Jay
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd))
{
$email .= fread($fd, 1024);
}
fclose($fd);
$splittingheaders = true;
$exploded = explode("\n",$email);
for($i = 0; $i < count($exploded); $i++){
if ($splittingheaders) {
if (preg_match("/^Subject: (.*)/", $exploded[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/[^From: ][\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $exploded[$i], $matches)) {
$from = $matches[0];
}
if ($exploded[$i]=="") {
// empty line, header section has ended
$splittingheaders = false;
}
// trying to pull out the message to no avail
if(preg_match("^Content-Transfer-Encoding: 7bit^",$exploded[$i],$msgs)){
$message = "GOT IT!\n";
$message .= $msgs[$i];
}
// end of trying to pull out message itself.
}
}
Eight bytes walk into a bar. The bartender asks, âCan I get you anything?â
âYeah,â reply the bytes. âMake us a double.â
Ask the Internet Marketing Geek <-- Happy to help with technical challenges
MiniSiteMaker.org <-- Free software to make your mini-sites fast and easy