MattWarren - 2006-06-02

what is wrong with this. file is saved as em.agi in agi-bin.  This is not sending the email.

#!/usr/bin/php4 -q
<?php
ob_implicit_flush(true);
set_time_limit(6);
$in = fopen("php://stdin","r");
$stdlog = fopen("/var/log/asterisk/my_agi.log", "w");

// toggle debugging output (more verbose)
$debug = false;

// Do function definitions before we start the main loop
function read() {
   global $in, $debug, $stdlog;
   $input = str_replace("\n", "", fgets($in, 4096));
   if ($debug) fputs($stdlog, "read: $input\n");
   return $input;
}

function errlog($line) {
   global $err;
   echo "VERBOSE \"$line\"\n";
}

function write($line) {
   global $debug, $stdlog;
   if ($debug) fputs($stdlog, "write: $line\n");
   echo $line."\n";
}

// parse agi headers into array
while ($env=read()) {
   $s = split(": ",$env);
   $agi[str_replace("agi_","",$s[[0])] = trim($s[[1]);
   if (($env == "") || ($env == "\n")) {
     break;
   }
}

    $sender = "call@domain.com";
    $recipient = "mwarren@domain.com";
    $subject = "call from someone";
   

   
    $header = "From: " . $sender . "\r\n";
    $header.= "Reply-to: " . $sender . "\r\n";

    mail($recipient, $subject, $message, $header);

fclose($in);
fclose($stdlog);

exit;
?>