tadakan Posted June 19, 2011 Share Posted June 19, 2011 I'm working on processing emails nearly instantaneously with a PHP CLI script that gets called by an email pipe. The email pipe is in hmail server. The script parses the email and then writes some bits into a text file. The problem I'm having is that if I send several emails in quick succession only the first one seems to interact with the script. The rest don't result in any behavior. I initially thought that my problem was with php's interaction with the text file so I tried writing some extra code to create a temp file and then copy it to the directory, but that doesn't seem to have changed the behavior at all so I'm wondering if it may be the email pipe that's the problem but I'm not sure how to go about tracking down the problem. Sorry for the run on sentences, it's been a long day. Here's my php: <?php //Get email contents when the server receives the email $email = file_get_contents('php://stdin'); //$email = "$395"; //Regular expression to find Value of the assignment $reg_exComp = '/\$(\d+)/'; //Apply the regex to the contents of the email and output to file preg_match($reg_exComp, $email, $comp); $i = 1; //Set the path and filename $filename = ("C:\\temp\\output".$i.".txt"); $dir = ("C:\\temp"); //if the file exists renumber the filename and rewrite the variable while(file_exists($filename)){ $i++; $filename = ("C:\\temp\\output".$i.".txt"); } //create the next highest filename and write to the file. $tmpfname = tempnam($dir, "tem"); $handle = fopen($tmpfname, "a"); fwrite($handle, $comp[1]); copy($tmpfname, $filename); fclose($handle); unlink($tmpfname); ?> Quote Link to comment https://forums.phpfreaks.com/topic/239780-php-cli-and-email-piping-dropping-calls-to-script/ Share on other sites More sharing options...
tadakan Posted June 19, 2011 Author Share Posted June 19, 2011 Looks like I just need to go to bed. It appears to be an email-related issue. Either my gmail (that I was using to send test emails from) is limiting how fast I can send emails to one address or hmailserver isn't accepting emails from one address really quickly. Either way, not a PHP issue. Apologies and thanks for your patience. Tom Quote Link to comment https://forums.phpfreaks.com/topic/239780-php-cli-and-email-piping-dropping-calls-to-script/#findComment-1231700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.