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;
Shell commandsudo 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.plist
to the propertylist, just before the last<key>RunAtLoad</key>
<true/></dict>
- Test with Shell commandto test your systems ability to send mail and
whoami | mail -s test youremailaddress@yourdomain.com
- Shell commandto test PHPs ability to do so.
whoami | php -r "mail('youremailaddress@yourdomain.com', '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.
FYI:
Step 3) says “Reboot and test with” – but no reboot is required! :)
I thought that too, but on 2 of 8 computers I did this, I really had to. Perhaps I’ll change it to ‘Step 3, in case it’s needed; reboot’ :)
Only need to restart postfix ;)