Part 1. Making, setting up, and installing Postfix.
There is another post on the site related to this, but I thought I’d put together a more coherent version, and assume that anyone reading this is already familiar with the Mac’s OSX setup. Especially the new version of El Capitan. Most notably from this version on, the lock down security. Which you can turn off if you wish, or disable for the duration of installs etc. That’s up to you. But – be aware that with it ON, you will have some problems installing certain features. Almost certainly.
OSX already comes with Postfix installed. It is all under the System owned directories, like /etc, /usr/bin. /usr/sbin and so on. It has a plist file in /System/Library/LaunchDaemons
You will want to disable this, because you will need to compile and install Postfix into local directories, like /usr/local, /usr/local/etc and so on. Why? Because if you don’t, when you UPDATE OSX, it will happily overwrite all your hard work, and set Postfix right back to where Apple wants it. If you put it where you want it, and modify the LaunchCtrl plist file to start it from there, updates to OSX will no longer trash your set up.
My base system:
OSX 10.11.1 on a Mac Mini. 16GB RAM. 2 TB HDD. Upper and Lower bays.
On this system I am running, and you will need at least these versions:
postconf -d | grep mail_version
mail_version = 3.0.2
mysql Ver 14.14 Distrib 5.6.25, for osx10.10 (x86_64) using EditLine wrapper
Connection id: 38052
Current user: robert@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ”
Using delimiter: ;
Server version: 5.6.25 Homebrew
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 7 days 17 hours 34 min 15 sec
Threads: 6 Questions: 2365733 Slow queries: 0 Opens: 1112 Flush tables: 1 Open tables: 725 Queries per second avg: 3.541
opendkim: OpenDKIM Filter v2.10.3
Compiled with OpenSSL 1.0.2d 9 Jul 2015
libmilter version 1.0.1
Supported signing algorithms:
Supported canonicalization algorithms:
Active code options:
libopendkim (check above command first. Some cases it is supplied)
OpenSSL 1.0.2d 9 Jul 2015
I think that’s it for necessary code. Just check that you have it all ready. The first thing you need to do is compile Postfix, and compile the Version 3.xx stable version.
Postfix Download Site.
Mirror Sites are here. Opens in another page. Choose the site nearest you and download the latest version, currently:
Postfix 3.0 stable release
On MY Mac, I have ended up with some things in odd places, in your case you may be the same or not. However, to start. Unpack the archive into a suitable directory below your Downloads folder. There may be a version difference by the time you read this, but the principal is the same. DON’T use an earlier version, as things are different.
Rushing right in, as one always does…. Don’t. You need to set up a few things.
After much fiddling about, I eventually put all of my notes into a file called make.txt, in that same directory. You can use vi right? Or vim as some call it. Try not to use a GUI text editor, apart from textMate, as most of them change the pure text to non-text characters, and make, and postfix, will barf on the files. Use VI. It’s worth learning. You are of course working from terminal anyway.
Ok, in my make.txt file I have the following notes. Related to building postfix, and to changing the default directories. Study it carefully.
The first thing is the make command. This one creates postfix, and when you install it, it installs it into the correct, user based location. You still have to install it as root however, because postfix needs to run as root. At least ‘master’ does. And that is the file that actually runs the whole thing.
My make. A very long single line. I tried breaking the lines, but it failed every time. Doing something wrong I guess.
Note the use of SASL, CYRUS, PCRE and DOVECOT. All of which you have installed or available right?
make -f Makefile.init dynamicmaps=yes CCARGS='-DHAS_MYSQL -I/usr/local/include/mysql -DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/opt/local/include/sasl -DDEF_SERVER_SASL_TYPE=\"dovecot\" -DHAS_PCRE -I/opt/local/include' 'AUXLIBS=-L/opt/local/lib -lsasl2 -lssl -lcrypto -licuuc' 'AUXLIBS_MYSQL=-L/usr/local/lib -lmysqlclient -lz -lm' 'AUXLIBS_PCRE=-L/opt/local/lib -lpcre' makefiles command_directory=/usr/local/sbin config_directory=/usr/local/etc/postfix meta_directory=/usr/local/etc/postfix daemon_directory=/usr/local/libexec/postfix mailq_path=/usr/local/bin/mailq newaliases_path=/usr/local/bin/newaliases sendmail_path=/usr/local/sbin/sendmail shlib_directory=/usr/local/lib/postfix
It’s not just about the locations either. Pay careful attention to where the libraries are on your system. Go find them if you aren’t sure. Also note the -DUSE options – indeed all the CCARGS. They are important. If not right, the thing won’t build.
From the postfix docs. You should read this carefully. All of those parameters are actually compiled and placed into the postfix. runtime configuration file, main.cf. Except the first one mentioned here.
4.6.1 – Postfix 3.0 and later
All Postfix configuration parameters can be changed by editing a Postfix configuration file, except for one: the parameter that specifies the location of Postfix configuration files. In order to build Postfix with a configuration directory other than /etc/postfix, use:
$ make makefiles config_directory=/some/where …other arguments…
The command “make makefiles name=value …” will replace the string MAIL_VERSION at the end of a configuration parameter value with the Postfix release version. Do not try to specify something like $mail_version on this command line. This produces inconsistent results with different versions of the make(1) command.
Parameters whose defaults can be specified in this way are listed below. See the postconf(5) manpage for a description (command: “nroff -man man/man5/postconf.5 | less”).
|parameter name||typical default|
On my build, I have these set. Check the make file. I haven’t changed ALL of them.
You can set these in the make file, or you can respond to the questions that make presents you with for their locations. I prefer the response type set up, so I can confirm what I am doing.
What can I say. Try it and see which one you prefer.
A final check.
In my Makefile – a text file in the directory, I have this right at the top. DO NOT edit. Yours should be somewhat similar.
# Do not edit -- this file documents how Postfix was built for your machine. #---------------------------------------------------------------- # Start of summary of user-configurable 'make makefiles' options. # CCARGS=-DHAS_MYSQL -I/usr/local/include/mysql -DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/opt/local/include/sasl -DDEF_SERVER_SASL_TYPE=\"dovecot\" -DHAS_PCRE -I/opt/local/include # AUXLIBS=-L/opt/local/lib -lsasl2 -lssl -lcrypto -licuuc # AUXLIBS_PCRE=-L/opt/local/lib -lpcre # AUXLIBS_MYSQL=-L/usr/local/lib -lmysqlclient -lz -lm # shared= # dynamicmaps=yes # pie= # command_directory=/usr/local/sbin # config_directory=/usr/local/etc/postfix # daemon_directory=/usr/local/libexec/postfix # mailq_path=/usr/local/bin/mailq # meta_directory=/usr/local/etc/postfix # newaliases_path=/usr/local/bin/newaliases # sendmail_path=/usr/local/sbin/sendmail # shlib_directory=/usr/local/lib/postfix # End of summary of user-configurable 'make makefiles' options.
With everything in place. Try a ‘make‘ It can’t hurt, so long as you don’t do ‘make install’ yet.
When the make runs through to the end – successfully, you are ready to install it. Not start it, just install it.
Also, you need a plist file change if you want to automatically start postfix each time. And – you need Dovecot, and other stuff installed as well.
End of Part 1.