php - Procmail, Plancake, and MySQL working together -
i've got script running when email address receives email, procmail pipes php script, parsed plancake, not many problems there. i've got if statement on strpos, depending on if body contains text. reason, when add together mysql code, entire thing stops working. unfortunately way it's setup i'm not quite sure how add together error checking. here's code:
<?php require_once("plancakeemailparser.php"); $rawemail = ''; if (($fp = fopen('php://stdin', 'r')) !== false) { while (!feof($fp)) { $rawemail .= fread($fp, 1024); } fclose($fp); } $emailparser = new plancakeemailparser($rawemail); $emailsubject = $emailparser->getsubject(); $emailbody = $emailparser->getplainbody(); $emailheader = $emailparser->getheader('from'); $message = "from: ".$emailheader."\n\nsubject: ".$emailsubject."\n\nbody: ".$emailbody; $status = 4; preg_match("/\d+/", "$emailsubject", $matches); $number = $matches[0]; $short = substr($message, 0, strpos( $message, 'begin')); if (stripos($short,'approve') !== false) { echo 'true'; $msg = approve; //file_put_contents('/home/symantec_mail/task' . $number . 'short.php',$msg); file_put_contents('/home/symantec_mail/task' . $number . 'approve_short_reply.txt',$message); file_put_contents('/home/symantec_mail/task' . $number . 'approve_reply.txt',$rawemail); } if (stripos($short,'complete') !== false) { echo 'true'; $msg = complete;
when uncomment next mysqli code, stops.
//$mysqli = new mysqli("localhost", "user", "pass", "db"); //$update = $mysqli->prepare("update task_overview set status = ? task_id = ?"); //$update->bind_param('ii', $status, $number"); //$update->execute();
rest of code.
//file_put_contents('/home/symantec_mail/task' . $number . 'short.php',$msg); file_put_contents('/home/symantec_mail/' . $number . 'complete_short_reply.txt',$message); file_put_contents('/home/symantec_mail/' . $number . 'complete_reply.txt',$rawemail); } ?>
really not sure why can't execute these commands. point out it's on different shell business relationship normal web server, although php still executing, i'm not sure if i'm communicating mysql server. please if have suggestions, if it's error checking i'll appreciate it.
php mysql email procmail
No comments:
Post a Comment