Piping email to PHP app -


i have php app built using slim routing framework. app needs send dynamic emails orders users can respond emails , response goes right app (stored in mysql). can create dynamic address per order , goes out fine. problem getting back.

i setup subdomain (mailer.example.com) , in cpanel setup forwarder catch mail subdomain , forward specific php file. php file reads stdin , grabs mime message , writes file:

#!/usr/bin/php -q <?php // read stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) {     $email .= fread($fd, 1024); } fclose($fd);  $filename = "mail_".date("mdyhis").rand(1,99999999); file_put_contents("mailfiles/".$filename, $email);  header("location: http://www.example.com/public/mailer/process/".$filename); 

as can see, @ end forward actual app has database calls , other routines process email. don't know how request app. seems ignore header call above.

am doing wrong or should processing need in script? realize maybe easiest path forward i'm trying use mail parse library fits nicely in app.

not sure if makes sense. let me know other info need.

i think you're looking isn't return http response location header, rather initiate http request web server.

in case, should replace header() call with:

$ch = curl_init('http://localhost/public/mailer/process/' . $filename); curl_setopt($ch, curlopt_returntransfer, true); $result = curl_exec($ch); 

note script (the 1 called save mail contents) wait app finish processing request. if issue you, you'll need use technique run php processes in background.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -