35

I can start Postfix temporarily with:

$ sudo launchctl
launchd% start org.postfix.master

However, Console.app shows that it only runs for a short time:

26/11/11 2:00:55.710 PM postfix/master: master exit time has arrived

I think the file /System/Library/LaunchDaemons/org.postfix.master.plist needs to be updated to make Postfix run permanently, but I haven't found the answer yet.

What's the correct way of getting Postfix starting at boot time and running permanently?

Update In order to edit the file as recommended by the selected answer, I first converted it to XML.

plutil  -convert xml1 /System/Library/LaunchDaemons/org.postfix.master.plist

Then just edited it with Vim:

sudo vim /System/Library/LaunchDaemons/org.postfix.master.plist

I had issues trying to get Xcode to edit the file.

mjturner
  • 4,945
dkam
  • 615

1 Answers1

36

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.

mjturner
  • 4,945
  • 1
    Worked for me on Mavericks, but I had to put the full file path in to load it: sudo launchctl load /System/Library/LaunchDaemons/org.postfix.master.plist – rich Apr 09 '14 at 16:55
  • 1
    There was a cd /System/Library/LaunchDaemons line in there before the unload and load that may have been missed. I inlined the full path to make it clearer. – Jim Stewart Jun 22 '15 at 19:58
  • On El Capitan, /System/Library/LaunchDaemons/org.postfix.master.plist is no longer editable. Suggestions? – Chris Withers Nov 23 '16 at 23:42
  • @ChrisWithers I've added some info. Basically, disable SIP, make the edits and re-enable. You'll need to boot from rescue media before you can enable/disable SIP though. – mjturner Nov 27 '16 at 13:28
  • i had to type "sudo postfix start" to mke it words instead of launchtl load stuff from mjturner; don't know why ... –  Jul 01 '15 at 12:38
  • 2
    @mjturner - disable the sip? nope nope nope... Much better is just to create a new .plist that you own in /Library/LaunchDaemons/ – Chris Withers Nov 28 '16 at 07:21
  • @ChrisWithers Fair comment (unfortunately your suggested edit was rejected, not by me). I prefer the disable/edit/enable approach so that it's more obvious but yours is also valid. – mjturner Nov 28 '16 at 22:46
  • 1
    @mjturner - yeah, that's weird. I didn't get any notification, and it's a bit sad. Care to make the same edit? – Chris Withers Nov 29 '16 at 09:59
  • @ChrisWithers Yep, will edit my answer this evening and include your suggestion. – mjturner Nov 29 '16 at 13:37
  • 3
    @mjturner On High Sierra, org.postfix.master.plist is renamed to com.apple.postfix.master.plist. Maybe you may want to add that to the answer. – Utku Dec 19 '17 at 00:21
  • I had to add <key>RunAtLoad</key> <true/> in order to get it to startup on boot (on High Sierra) – Jimbo Jan 17 '18 at 00:10
  • 1
    @mjturner: Putting the custom plist in LaunchDaemons doesn't start the custom daemon, because the original is already running, effectively taking precedence. So every time I restart my computer, I have to first unload the original daemon and then load the custom manually using launchctl from Terminal. Is there a way to make macOS (I'm on 10.12) run the modified version of Postfix automatically on startup without messing with SIP? – forthrin Mar 31 '18 at 19:02