Mountain Lion killed – or rather: disabled – sendmail by default. Big deal? well, if you need to send mail from PHP in your local development environment, you’ll need to perform these few steps to get it working again.
- To start postfix the first time, you’ll need to prepare the system a bit;
sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start
- Then you probably want postfix to be started on every boot;
Edit(sudo nano ….) and add
/System/Library/LaunchDaemons/org.postfix.master.plistto the propertylist, just before the last
- Test with Shell commandto test your systems ability to send mail and
whoami | mail -s test email@example.com
- Shell commandto test PHPs ability to do so.
whoami | php -r "mail('firstname.lastname@example.org', 'test', reset(file('php://stdin')));"
Please note: your mail may be regarded as spam since your sender-domain will undoubtedly not match your IP-address. Don’t hold me responsible. If you need to send a lot of mail this way, consider configuring postfix to use Authenticated SMTP and send the mail through your mail-providers SMTP server.
Also note; in some cases a reboot is needed between steps 2 and 3.