What's the correctly way to make Postfix run permanently on Lion (not server)

Solution 1:

The following changes worked for me:

  1. Remove the following two elements from /System/Library/LaunchDaemons/org.postfix.master.plist:

    <string>-e</string>
    <string>60</string>
    

    This will stop it exiting after 60 seconds.

  2. Add the following element as a child of the <dict>...</dict> element in the same plist file:

    <key>KeepAlive</key>
    <true/>
    
  3. Reload the file:

    sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist 
    sudo launchctl load /System/Library/LaunchDaemons/org.postfix.master.plist
    

postfix should now be running as a daemon.

The above works on Mountain Lion, Mavericks, Yosemite and El Capitan. For systems that have System Integrity Protection (El Capitan and later) there are two options:

  1. Copying /System/Library/LaunchDaemons/org.postfix.master.plist to /Library/LaunchDaemons/org.postfix.custom.plist, changing org.postfix.master to org.postfix.custom and then unloading and loading as above.
  2. Disabling SIP (using csrutil), making the edits and then re-enabling SIP.

Note: With High Sierra and Mojave, the configuration file is com.apple.postfix.master.plist instead of org.postfix.custom.plist.