when I send mail to my pipe script, the script works fine, but the server also bounces the mail back to report the PHP version, outputting in the bounced message:

X-Powered-By: PHP/4.4.7
Content-type: text/html

(This is not my script mailing me; it's my original mail bouncing back. Also, this pipe works fine on another server, and the script has no output itself.) I have read that it is possible to turn off this output by setting

expose_php off

in php.ini (this option cannot be set with ini_set() ), but as I am on a shared server I don't have access to php.ini.

I then learned that it is possible to put php.ini in the same directory as the script in order to override the default php.ini. I asked my hosting provider to send me a copy of php.ini so I could make the relevant modification to expose_php and stick the file in the folder with my pipe script. They sent me a php.ini file with only the expose_php setting in it. Specifically, this php.ini file contained only:

php_flag expose_php off

Adding this file to the directory of the pipe script changed nothing, so I asked them to send the whole php.ini file, intending to edit the relevant setting myself. They declined to do for "because it includes special options that affect other clients on the server we can not disclose," and claimed that "it is possible to create a php.ini file under the local directory and just specify the options by setting only the necessary arguments that are needed for the account. This php.ini file will override the original php.ini file in the server. Therefore there is no need to have the entire php.ini file contents."

So it seems either it is not true that I can use a php.ini file in my local directory with only the required arguments specified to solve this problem (ie, just "php_flag expose_php off"), or there is some argument in php.ini in addition to "php_flag expose_php off" that needs to be specified to turn off this output.

What's the best way to fix this? Thanks for your help.

    On most shared servers, there is only one system-wide php.ini file which can only be modified by the system administrators. If running on Apache and if the host has not disabled it, you can put a .htaccess (note the leading ".") file in your local directory, then add that configuration item to it.

    However, I'm not entirely sure what the problem is you are describing, nor why that particular configuration setting would be showing up in email headers (assuming that is what you are describing).

      NogDog wrote:

      On most shared servers, there is only one system-wide php.ini file which can only be modified by the system administrators. If running on Apache and if the host has not disabled it, you can put a .htaccess (note the leading ".") file in your local directory, then add that configuration item to it.

      However, I'm not entirely sure what the problem is you are describing, nor why that particular configuration setting would be showing up in email headers (assuming that is what you are describing).

      to be more specific, let's say I'm piping to a simple script like

      #!/usr/bin/php
      <?php
      $x=1;
      ?>
      

      The script will run fine (ie, if a similar script to which I pipe stores a value in the database, that will work, so I know the script is running). However, invariably the message I send to the address that pipe forwards to the script gets bounced back to me, which I don't want to happen (and hasn't happened when I ran the script on another server).

      The bounce says:

      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 |/usr/home/godshalk/public_html/myurl.com/another_pipe_test.php
         generated by another_test@myurl.com
      
      The following text was generated during the delivery attempt:
      
      ------ pipe to |/usr/home/godshalk/public_html/myurl.com/another_pipe_test.php
            generated by another_test@myurl.com ------
      
      X-Powered-By: PHP/4.4.7
      Content-type: text/html
      
      (message header and message follow this)
      

      this is the same bounce I get if the script has a syntax error (in which case the bounce contains the error output, such as "unexpected ( on line 90" or whatever), except there is no error -- it's just reporting the PHP version number, and content type.

      so my goal is to stop this bounce from happening, and my understanding is that I can do this if I somehow turn off the 'X-Powered-By' etc. output. (though I may be wrong here), and that I should be able to turn off this output using the expose_php setting in php.ini (which may also be wrong). I do know that expose_php can only be changed within php.ini (according to php.net), which I assume means I can't use .htaccess to do it.

      let me know if I can provide any additional information, thanks again

        I would be more inclined to think it's coming from within the PHP script itself that is generating the email via PHP's mail() function, including that as one of the headers in the "additional headers" argument to the mail() function.

        My understanding of the the expose_php configuration setting is that it has to do with web server headers (see http://www.php.net/manual/en/ini.core.php#ini.expose-php) rather than anything to do with the mail() function.

          hm, well my script itself doesn't actually use the mail() function, so I am confused why the script would call it. I did a bit more googling and I found the following info:

          "for a PHP powered website, PHP engine will add its information to the headers regardless of Apache configuration:
          Server: Apache
          X-Powered-By: PHP/4.3.11

          To avoid this, turn off expose_php in php_ini:
          expose_php = Off"

          that does seem like what I want to do.. if I can only figure out how to turn expose_php off without having access to the main php.ini...

          (I got that quotation from http://www.itslot.com/hide_apache_and_php_information_in_http_headers )

          update: this seems to corroborate that idea, but when I follow this advice I have no luck: http://www.webmasterworld.com/forum88/1828.htm

          thanks for your help. any additional suggestions appreciated

            well, my host seems to think that expose_php can only be set in the server's main php.ini file, and not in a local php.ini file. the host cites as evidence of this the entry for expose_php at http://in.php.net/manual/en/ini.php#ini.list, which says only that it can be set in php.ini, as far as I can tell, and says nothing about restricting the setting to the main php.ini file versus setting expose_php in the local file.

            also the link in my last post suggests that it is possible to change expose_php in a local file.

            does their interpretation of the php.net info sound correct?

              10 days later

              Your mail server thinks the script is outputting an error (to be bounced back; ie-custom spam filtering done through a pipe).

              To stop this, have your script return NULL.

              #!/usr/bin/php
              <?php
              //do some stuff
              
              return NULL;
              ?>

                More precisely, I believe you need to return the integer 0 to indicate success.

                  Write a Reply...