Please note that this information is no longer up to date. The content of this site has moved to a new domain DIYMacServer.com which is kept up to date. Apologies for the inconvienince.
We’ve got everything compiled and configured to its time to try to start everything up and to test if it’s working properly. And last but not least is how can you have everything start-up automatically after a reboot. Apache and MySQL have been configured to start after a reboot now it’s time to take care of the mailserver components.
Courier Auth daemon
To have the Courier Authentication daemon to start at a boot you’ll have to do the following as a root using the Terminal:
Create a directory CourierAuth
in the directory /System/Library/StartupItems
The easy next step is to copy the contents of the Apache startupitem to your new directory using:
cp /System/Library/StartupItems/Apache/* \ /System/Library/StartupItems/CourierAuth
Then rename the Apache shell script to CourierAuth using:
mv /System/Library/StartupItems/CourierAuth/Apache \ /System/Library/StartupItems/CourierAuth/CourierAuth
Next you need to edit the renamed file /System/Library/StartupItems/CourierAuth/CourierAuth
and have it look like:
#!/bin/sh ## # Courier Authentication mailserver ## . /etc/rc.common StartService () { if [ "${CAUTHSERVER:=-NO-}" = "-YES-" ]; then echo "Starting Courier Auth server" /usr/local/sbin/authdaemond start fi } StopService () { echo "Stopping Courier Auth server" /usr/local/sbin/authdaemond stop } RestartService () { if [ "${CAUTHSERVER:=-NO-}" = "-YES-" ]; then echo "Restarting Courier Auth server" StopService StartService else StopService fi } RunService "$1"
The other file to edit in this directory is StartupParameters.plist
, have it look like:
{ Description = "Courier Auth server"; Provides = ("Authentication Server"); Uses = ("Disks", "NFS"); }
The last thing to do is to add the following line to the /etc/hostconfig
file:
CAUTHSERVER=-YES-
You’re done for this item, on to the next…
Courier IMAP daemon
The IMAP daemon is configured the same as the authentication daemon, the difference is in the details.
Create a directory CourierIMAP
in the directory /System/Library/StartupItems
The easy next step is to copy the contents of the Apache startupitem to your new directory using:
cp /System/Library/StartupItems/Apache/* \ /System/Library/StartupItems/CourierIMAP
Then rename the Apache shell script to CourierIMAP using:
mv /System/Library/StartupItems/CourierIMAP/Apache \ /System/Library/StartupItems/CourierIMAP/CourierIMAP
Next you need to edit the renamed file /System/Library/StartupItems/CourierIMAP/CourierIMAP
and have it look like:
#!/bin/sh ## # Courier IMAP server ## . /etc/rc.common StartService () { if [ "${IMAPSERVER:=-NO-}" = "-YES-" ]; then echo "Starting Courier IMAP server" /usr/local/libexec/imapd.rc start fi } StopService () { echo "Stopping Courier IMAP server" /usr/local/libexec/imapd.rc stop } RestartService () { if [ "${IMAPSERVER:=-NO-}" = "-YES-" ]; then echo "Restarting Courier IMAP server" StopService StartService else StopService fi } RunService "$1"
The other file to edit in this directory is StartupParameters.plist
, have it look like:
{ Description = "Courier IMAP server"; Provides = ("IMAP Server"); Uses = ("Disks", "NFS"); }
The last thing to do is to add the following line to the /etc/hostconfig
file:
IMAPSERVER=-YES-
Note: If you configured the IMAP server to use SSL and/or TLS you need to replace imapd.rc
in StartupItems script with imapd-ssl.rc
because the SSL option requires a different program to startup.
You’re done for this item, on to the last…
Postfix
The Postfix daemon is configured the same as the authentication and IMAP daemon, the difference is in the details.
Create a directory Postfix
in the directory /System/Library/StartupItems
The easy next step is to copy the contents of the Apache startupitem to your new directory using:
cp /System/Library/StartupItems/Apache/* \ /System/Library/StartupItems/Postfix
Then rename the Apache shell script to Postfix using:
mv /System/Library/StartupItems/Postfix/Apache \ /System/Library/StartupItems/Postfix/Postfix
Next you need to edit the renamed file /System/Library/StartupItems/Postfix/Postfix
and have it look like:
#!/bin/sh ## # Postfix mail server ## . /etc/rc.common StartService () { if [ "${MAILSERVER:=-NO-}" = "-YES-" ]; then echo "Starting Postfix mail server" postfix start fi } StopService () { echo "Stopping Postfix mail server" postfix stop } RestartService () { if [ "${MAILSERVER:=-NO-}" = "-YES-" ]; then echo "Restarting Postfix mail IMAP server" postfix reload else StopService fi } RunService "$1"
The other file to edit in this directory is StartupParameters.plist
, have it look like:
{ Description = "Postfix Mail server"; Provides = ("Mail Server"); Uses = ("Disks", "NFS"); }
The last thing to do is to add the following line to the /etc/hostconfig
file:
MAILSERVER=-YES-
You’re done, try a reboot if you dare… to check if it all works.
November 12th, 2006 at 11:29 pm
Why do you install them in /System/Library and not /Library?
This is in general, not recommended.
The httpd starts up as user daemon, cant read or write postfixadmin which has been set to www:www
November 13th, 2006 at 12:01 am
I don’t exactly know why I did this, it’s been a while… Could you elaborate on the why ?
The httpd daemon should run as www:www, it’s safer that way. I’ll correct the documentation for the apache install.
November 19th, 2006 at 2:20 am
Hi Richard,
Any idea why Apple Mail fails to download the full folder list from any virtual email account?
It sees the inbox, but there is no drafts or junk. Nor do the the sent items appear.
December 13th, 2006 at 9:52 pm
Hello Stephen,
your problem has nothing to do with this specific installation. Courier-IMAP works with one “home-folder” named INBOX. Only within this folder you can create, modify or create new folder. Just go to Mail -> Preferences -> Accounts -> Advanced and set INBOX as IMAP-path-prefix.
Richard – thanks for the great hints in your tutorial! Compiling on MacOS X is really more complicated than on Linux.
Jan
February 13th, 2008 at 1:45 am
[...] to get it to start on boot I followed these instructions (see towards the [...]
June 8th, 2008 at 8:22 pm
How can I write to start Courier POP daemon when I login?
June 8th, 2008 at 9:14 pm
I don’t understand why you would want this but you can by adding the startup script to the “Login Items” in the Accounts panel in the System Preferences.
June 10th, 2008 at 9:40 am
Thank you for the reply.
I used your IMAP Startup-Item-script as a blueprint. It is working.