Hi,
I just read thought a tutorial on how to email pipe via evolk.
When i try to send an email to the email address that is suppose to do the job, i get an error.
"Mail delivery failed: returning message to sender
pipe to |/home/username/public_html/pipe/email_pipe.php
generated by test@website.com
local delivery failed
"
I dont know what i am doing wrong. Any suggestions? My code is below:
#!/usr/bin/php
//header('Content-Type: text/html; charset=utf-8');
require_once ('includes/functions.inc.php');
require_once ('includes/mysql_connect.php');
// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
// handle email
$lines = explode("\n", $email);
// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;
//we have processed the headers and can start adding the lines to $message.
for ($i=0; $i < count($lines); $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;
}
$a = "RE: [119-24] Work Order Request - test - dsfsd";
preg_match("/\[[0-9]*-[0-9]*\]/",$subject,$matches);
list($jobid, $custid) = split('[-]', $matches[0]);
}
$cur_date = returnLocalDate();
$cur_time = returnLocalTime();
$insertQ = mysql_query("INSERT INTO test_pipe (job_id, cust_id, description, reply_date, reply_time, displayed)
VALUES ($jobid, $custid, '$message', '$cur_date', '$cur_time', 1)") or trigger_error("Query: $insertQ\n<br />MySQL Error: " .mysql_error());
if (mysql_affected_rows() > 0) {
$new_reply_id = mysql_insert_id();
echo $new_reply_id;
}
note: my Server API is CGI.