Posted by ahmadster at July 30th, 2006
As expected, the default Postfix that comes with OSX is not compiled with PostgreSQL support. I’m not sure if it did have TLS support though, anyway a quick run of otool like this
otool -L /usr/libexec/postfix/master
should show all the libraries the postfix master daemon is linked against. I already replaced mine so check it out in your machine.
Which brings us to the bad news. I intended to put everything in /usr/local/postfix. But I forgot to set the prefix and I replaced the apple provided postfix 
The good news is that it almost didn’t matter at all. Everything installed exactly where it should by default. And OSX is almost totally happy. I say almost because there has been a small wrinkle, I’ll explain later on.
Down to Business
Download the postfix source and untar (I got 2.2.10). All README files are in a big dir together, what I really cared about is PostgreSQL and TLS support, so here is how I got it to compile
make tidy
make -f Makefile.init makefiles 'CCARGS=-DHAS_PGSQL -I /usr/local/pgsql/include' 'AUXLIBS=-L/usr/local/pgsql/lib -lpq -lssl -lcrypto'
make
That should take care of compiling. Now install
make install
You will be asked a bunch of questions, mostly about the dir locations of stuff. The first one is the most important one. It’s the one I screwed up on. I accepted the default, which installed everything on /. You should probably use /usr/local/postfix or something like that.
Anyway, everything looks fine except for …
The Wrinkle: It Won’t Run!
You will get a bunch of failures in the console about some session permission denied. Postfix from Apple uses launchd, if you look at
/System/Library/LaunchDaemons/org.postfix.master.plist
You will find that it runs the master directly. The postfix folks have taken it upon themselves to officially not like that. I kept reading about how Apple is to blame etc…
Well that don’t do me no good now, does it?
It turns out in the Postfix source code there is a SystemStarted script in the auxiliary/MacOSX dir. Copy it over to /Library/StarterItems and you are ready. Edit /etc/hostconfig and add
POSTFIX=-YES-
Now here is how you start it up
sudo SystemStarted start SMTP
We used SMTP because that’s what the StarterItem provides. Look at StartupParameters.plist. Now make sure the launchd method isn’t used anymore,
cd /System/Library/LaunchDaemons/
sudo launchctl stop org.postfix.master
sudo launchctl unload org.postfix.master.plist
sudo mv org.postfix.master.plist org.postfix.master.plist.disabled