Guest helpbytes Posted June 9, 2005 Posted June 9, 2005 Well I tried to get answers to this through a ticket, but I am apparantely supposed to ask for "Developer level support" here, because there is nothing wrong with the service. I am trying to use the email filtering section of cpanel to send all email with a subject of HELPBYT to a php script, so I have it setup like this: subject equals HELPBYT action: |/home/helpbyt/public_html/blahblah.php I run a test, but the script is not called. No error is shown anywhere. I know it doesn't work because the script opens a text file and writes hello to it. The script works because if called from a browser, all goes well, the file is written to. So I tried to email myself from a gmail account, with the subject HELPBYT. The script is not called, and in addition the email bounces with this error: >This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: pipe to |/home/helpbyt/public_html/blahblah.php generated by helpbytes@helpbytes.co.uk local delivery failed That to me suggests the mail server doesn't quite understand "pipe to" is a command and not an address? Which would be a server problem? OK, in addition to this, I also did a filter to send the mail with the subject BOO to my gmail account, when I did this test, that email never went anywhere, not gmail and not my domain account on tch. The code of blahblah.php ><?PHP $fp = fopen("blahblah.txt","w"); fwrite($fp,"Hello"); fclose($fp); ?> Here is the .filter file from my home directory >$header_subject: contains "BOO"+++++++swnshp@gmail.com $header_subject: is "HELPBYT"+++++++|/home/helpbyt/public_html/blahblah.php Quote
TweezerMan Posted June 9, 2005 Posted June 9, 2005 I've never used e-mail filters, but it seems to me that there may be at least two problems with your script, stemming from the fact that the filter script must run from the command line instead of being run by the web server: 1) The script must have a shebang line for the first line so the shell knows what interpreter to use to run the script: >#!/usr/bin/php -q 2) The script must have execute permissions - the script's permissions should be set to 0755. Without the shebang line, the script would fail with something like a "bad interpreter" error message, and if the script is not executable, the script would fail with something like a "no execute permissions" error message. I imagine you don't see any error messages because these errors would be reported back to the mail server process, since that is what is trying to call your script. Hope this helps... Quote
TweezerMan Posted June 10, 2005 Posted June 10, 2005 One more tip: Your script should return a value of '0' when it ends to indicate that no error occurred. I'd suggest the following code for your script: >#!/usr/bin/php -q <?php $fp = fopen("blahblah.txt","w"); fwrite($fp,"Hello"); fclose($fp); return 0; ?> (and make sure the script has 0755 permissions.) Quote
Guest helpbytes Posted June 10, 2005 Posted June 10, 2005 Weird, I'm sure I replied to this earlier saying thanks, now it's gone lol The problem was actually the missing first line yes, I got carried away trying to work out the error and forgot that. Thanks for that. Quote
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.