Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts

Sendmail pipe php script dilemma

Posted by plattapuss on November 28th, 2006

Spent a little bit tonight getting sendmail to pipe one address to a php script. My searching for solutions never gave my exact solution so here is what I did to get this working.

The setup: Ensim on RHEL4. Installed PHP script sits on the main servers site which sits in /var/www/html and not on a virtually hosted site. The script is called pipe.php and sits in /var/www/html/order/pipe/pipe.php

Step 1: Add an alias in /etc/alias for my support email. Be sure to rebuild the alias file after by typing newaliases at the command line.
support: "|/usr/bin/php -q /var/www/html/order/pipe/pipe.php"

Step 2: chmod the script so it is executable:

chmod 755 /var/www/html/order/pipe/pipe.php

Step 3: Create a symbolic link in /etc/smrsh so sendmail will know about my script. If you don't do this then sendmail will spit out the wholly ugly error message Service unavailable, and smrsh: "php" not available for sendmail programs (stat failed).

cd /etc/smrsh
ln -s /usr/bin/php ./php
ln -s /var/www/html/order/pipe/pipe.php ./pipe.php

Now all you need to do is test the functionality of your new script by sending an email to support@yoursite.com.

Note, that if you are installing a script on a virtual site you need to make the above changes in the virtual site files. So instead of adding links in /etc/smrsh you would add them in /home/virtual/siteXX/fst/etc/smrsh and instead of adding the alias in /etc/aliases, you would add them in /home/virtual/siteXX/fst/etc/aliases. Then to rebuild the aliases DB, you need to do this:

/usr/sbin/chroot /home/virtual/siteXX/fst newaliases

That is about all there was to it. The error messages I got back from sendmail took me a bit to figure out.



Reader Comments

Very interesting, indeed.
Especially the part related to smrsh