Getting Postfix running on a MacBook with Snow Leopard
Published on Tuesday, 17 March 2009.
Because I use my MacBook Pro for development, I needed to install an SMTP daemon on my box so that it would handle email routing. I have been doing some Ruby on Rails development and after installing restful-authentication (which implements an email based authorization for new user accounts), it made me aware that I had to setup my SMTP services. It also broke some of my functional tests, which test this functionality. I was getting errors like:
1) Error: test_should_activate_user(UsersControllerTest): Errno::ECONNREFUSED: Connection refused - connect(2)
I thought the connection error was being caused by the rails app or database, but as it turns out it was that I did not have an SMTP server running on my local box. The SMTP setting are located (in my Rails Project) at config/initializers/mail.rb.
As I understand it, Postfix is installed by default on Leopard, but it is not set to start automatically when the OS boots. a couple of quick changes to the /System/Library/LaunchDaemons/org.postfix.master.plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.postfix.master</string>
<key>Program</key>
<string>/usr/libexec/postfix/master</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>master</string>
<string>-e</string>
<string>60</string>
</array>
<key>QueueDirectories</key>
<array>
<string>/var/spool/postfix/maildrop</string>
</array>
</dict>
</plist>
Take note of the section
<key>OnDemand</key>
<false/>
This is the only section I had to change.
Then did the following:
sudo launchctl stop org.postfix.master sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist sudo launchctl load /System/Library/LaunchDaemons/org.postfix.master.plist sudo launchctl start org.postfix.master
Tested it:
swoolley@~>telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 steve-woolleys-macbook-pro.local ESMTP Postfix quit 221 2.0.0 Bye Connection closed by foreign host.
Good to go! Try rebooting your Mac to make sure it comes up on boot.