Aug 10 2011
This might not be news to experienced PHP developers, but as a newb it did take me a few days to track this error down, and I could not find any help on the net for it. So I’m writing it here:
First of all, the cause: I was running in PHP’s safe mode. The fix: disable safe mode in PHP’s configuration; in my case this was an edit to php.ini.
As for the process that led me there: I host a Joomla! website on Midphase. Joomla! has a password reset mechanism, which uses email verification. At some point in the past few weeks this mechanism stopped working on my site. The problem was that the verification emails were not sent, as the PHP code, which tries to execute sendmail, failed to do this.
I tried to figure out the problem, tried setting Joomla! to use direct SMTP or PHPMailer instead, but SMTP didn’t work for some other reason, and PHPMailer actually uses either sendmail or SMTP itself, so that was not a real solution. I added various debug code to the original Joomla!/PHPMailer code in order to debug this problem, and ended up receiving this error message at the attempt to execute sendmail:
sh: /usr/local/php/bin/sendmail: No such file or directory
This was very strange, as there really is no sendmail in /usr/local/php/bin. I tried figuring out what was sending the code to look for sendmail in the wrong place, tried setting everything that I could think of (php.ini, Joomla! configuration, hard-coding values into phpmailer.php) but still got this same error.
In the end I somehow mentally stumbled over the PHP-safe-mode idea, and immediately went to set this value in php.ini. And that’s that. PHP’s safe mode disallows execution of external programs unless they are in one of the specially-specified directories. I opted to turn safe mode off altogether due to the notes in php.net that this mode is deprecated (they say it’s not really safe), and has in fact been removed from the newer versions of PHP.
I can only assume that recent server transitions in Midphase moved my site to a server where the default PHP configuration had safe mode at *on*, where the old server had it at *off*.
Hope this helps someone