. . . . "" "=C9=C9=C9" .. . . .
#!/usr/local/bin/php -q
<?php
// Initialize variables
$from = "";
$to = "";
$allheaders = "";
$otherheaders = "";
$emailfeed = "";
$message = "";
$splittingheaders = true;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";

// Get the email from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

// Parse the email line by line into an array
$lines = explode("\n", $email);

// For each of the lines in the email
for ($i=0; $i<count($lines); $i++) {
// If we are separating the headers out from the message body
if ($splittingheaders) {
$allheaders .= $lines[$i]."\n";

// Look out for special headers
if (preg_match("/^from: (.*)/i", $lines[$i], $matches)) {
$from = $matches[1];
$fromEmail = ereg("([[:alnum:]_\.\-]+@([[:alnum:]_\.\ -]+\.)+[[:alpha:]]{2,4})", $from, $emailMatch);
$fromEmail = $emailMatch[1];
}
elseif (preg_match("/^to: (.*)/i", $lines[$i], $matches)) {
$to = $matches[1];
}
else {
$otherheaders .= $lines[$i]."\n";
}
}
else{ // Add this line to the message body
$message .= $lines[$i]."\n";
if (preg_match("/^emailfeed: (.*)/i", $lines[$i], $matches)) {
$emailfeed = $matches[1];
}
else {
$otherheaders .= $lines[$i]."\n";
}
}

// If the line is blank
if (trim($lines[$i])=="") {
// The header section has ended
$splittingheaders = false;
}
}
// If the user isn't from our domain and hasn't sent too many recent emails
if(!strpos($from, '@xxx.com')) {
// Then send an autoresponse back to the user
mail("$from", "", "$emailfeed", "$headers");
}
?>