If you want to send SMTP mail via localhost on Mac OSX Leopard (for example, from ActiveRecord/Rails/CruiseControl.rb/etc), you need to run postfix at boot. This took me a quite a while to figure out, so here is what worked for me on a work-imaged box and my personal box. YMMV.
- First, Leopard comes with postfix, but I had numerous issues because I had the MacPorts version already installed on all my boxes for whatever reason. Here are the various error search strings for future googlers:
fatal: file /opt/local/etc/postfix/main.cf: parameter mail_owner: user postfix has same user ID as _postfix
fatal: open /usr/local/etc/postfix/main.cf: No such file or directory
fatal: open /opt/local/etc/postfix/main.cf: No such file or directory
- So, I ended up uninstalling the MacPorts version:
$ sudo port uninstall postfix
- Strangely, after this, I still get a version @2.5.4 returned by “
sudo port list postfix
“, even though the uninstall was apparently successful. I don’t know enough about MacPorts to know why, maybe this is reporting the Leopard-installed one???
- Strangely, after this, I still get a version @2.5.4 returned by “
- Next, I edited the plist file to start postfix automatically on boot:
$ sudo vi /System/Library/LaunchDaemons/org.postfix.master.plist`
- Add these entries at the bottom, in the ‘dict’ element
<key>RunAtLoad</key> <true> <key>OnDemand</key> </true><false> </false>
- Add these entries at the bottom, in the ‘dict’ element
- Reboot
- Make sure SMTP port 25 is open on localhost
$ telnet localhost 25
- Look for something like the following, showing you connected successfully on localhost:
Trying ::1... telnet: connect to address ::1: Connection refused Trying fe80::1... telnet: connect to address fe80::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 citestbox.localhost ESMTP Postfix
- Hit Ctrl-] to get to the telnet> prompt
- Type quit to exit
And that was it! CruiseControl.rb was now sending email from OSX, which was all I really wanted in the first place…
About the Author