Ubuntu, Sendmail and PHP
28 Mar 2005Surprisingly, I hadn’t noticed until just yesterday when I was testing out a contact form for a website under development that my PHP mail()
wasn’t working properly. I really should have — WordPress sends out moderation emails for comments, and the absence of those in testing should have made me think twice, but it didn’t.
So, PHP and Sendmail weren’t playing nice. The default command is sendmail -t -i
, if you don’t manually set sendmail_path
in your php.ini
configuration, but this wasn’t working.
Unfortunately, due to some degree of stupidity in the way things are run, you need to use an absolute path for PHP to find where it is (even if just the command “sendmail” works fine from a terminal… like I said, stupid), so if you want mail, you have to play by its rules. For no apparent reason.
This is all with stock Ubuntu versions of Apache2 and PHP, by the way — the stupidity may go away if you do-it-yourself, but I’m kind of doubting it.
Anyway, assuming you’ve got sendmail (or an MTA which provides sendmail hooks — I’m actually using postfix here) installed, you can simply set this in your php.ini, restart Apache (using apache2ctl restart
from a root account), and all should be working:
sendmail_path = /usr/sbin/sendmail -i -t
Bingo!