Everything is compiled, installed and configured to its time to try to start everything up and to test if it is working properly. Apache and MySQL have been configured already to start after a reboot, now it’s time to take care of the mailserver components Postfix and Dovecot.

Postfix
Create a file called ‘com.diymacserver.postfix.plist‘ in the directory ‘/System/Library/LaunchDaemons/‘. The content of the file should look like:

<?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>com.diymacserver.postfix</string>
  <key>Program</key>
  <string>/usr/local/libexec/postfix/master</string>
  <key>ProgramArguments</key>
  <array>
    <string>master</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>OnDemand</key>
  <false/>
</dict>
</plist>

To load and activate the .plist file and to make sure that it is started after a reboot you’ll need to load the plist file by using the command:

sudo launchctl load /System/Library/LaunchDaemons/com.diymacserver.postfix.plist

To make sure the original postfix won’t be started execute the command:

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

You can see if it loaded correctly by using the command:

sudo launchctl list

This will show you all the active plist files.

You can see if everything went correctly by trying to start it using:

sudo launchctl start com.diymacserver.postfix

Dovecot
The Dovecot server is configured almost the same as Postfix, the difference is in the details.

Create a file called ‘com.diymacserver.dovecot.plist‘ in the directory ‘/System/Library/LaunchDaemons/‘. The content of the file should look like:

<?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>com.diymacserver.dovecot</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/sbin/dovecot</string>
    <string>-F</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
</dict>
</plist>

To load and activate the .plist file and to make sure that it is started after a reboot you’ll need to load the plist file by using the command:

sudo launchctl load /System/Library/LaunchDaemons/com.diymacserver.dovecot.plist

You can see if it loaded correctly by using the command:

sudo launchctl list

This will show you all the active plist files. Dovecot should have been started now.

If you look at the logfile ‘/var/log/mail.log‘ you could see if all programs started succesfully.