The basic mail-server setup is based on Postfix from Wietse Venema and the Courier IMAP and POP3 server. This mail-server is already included in the standard installation of Mac OSX but it lacks some important features if you want to receive mail from more than one user on different domains. To do that you need some more extensions and added features to de-couple the Postfix user management from the OS X user management, add some virtual domain handling, enable the users to send the mail securely over SSL and don’t open the server for abuse.

To be able to do this you need to compile Postfix with support for MySQL (user management), SASL (authentication), TLS (SSL) and use Courier IMAP (virtual mailboxes) or POP3 to have people look into their mailbox.

Building the components:

Configuring the components:
When everything is build and installed you are ready to configure all the separate components before we can start it up. I will explain most of the configuration settings as we go along when possible.

Get everything running:
Now everything is compiled and configured it iss time to start everything up and to test if it is working properly. This step also takes care of having everything start-up automatically after a reboot. Apache and MySQL have already been configured to start after a reboot now it is time to take care of the mailserver components.

Note:

Many problems I received from people who tried this themselves didn’t start on a cleanly installed OS. They had multiple instances of MySQL installed or had some libraries left over from something else. You need to make sure where the include files and the libraries are of the MySQL installation you are going to use. You can find that out by running the ‘mysql_config’ command which will show you the location of the include files and libraries among some other things. If you used the MySQL.com installation package the output would look like:

# mysql_config
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Options:
–cflags [-I/usr/local/mysql/include -Os -arch ppc -fno-common]
–include [-I/usr/local/mysql/include]
–libs [-L/usr/local/mysql/lib -lmysqlclient -lz -lm]
–libs_r [-L/usr/local/mysql/lib -lmysqlclient_r -lz -lm]
–socket [/tmp/mysql.sock]
–port [3306]
–version [5.0.19]
–libmysqld-libs [-L/usr/local/mysql/lib -lmysqld -lz -lm]
#

Next step: Building SASL