PHP Sendmail under Mountain Lion

With an upgrade to Mac OS X 10.8 (Mountain Lion), PHP's sendmail() inexplicably ceased working. I knew that a number of things got re-defaulted (like /etc/paths) but this seemed a bit different.

The telltale error message in your Apache log is:

sendmail: fatal: chdir /Library/Server/Mail/Data/spool: No such file or directory

To fix this problem, simply do:

sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start

Please note that you will see some warnings when you execute those commands, but it will work, I promise!

References

  • http://apple.stackexchange.com/questions/54051/sendmail-error-on-os-x-mountain-lion
  • http://stackoverflow.com/questions/11696609/php-mail-no-longer-works-after-update-to-osx-mountain-lion