Postfix will complain about not having SASL and TLS support compiled in, so I got the latest cyrus sasl from ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/. Cyrus does not check SQL passwords that are stored using crypt or other methods. To enable that, I modified a small patch I found online. The only modification is I changed -lcrypt to -lcrypto, and it worked
patch -p0 < cyrus-sasl-2.1.19-checkpw.c.patch
./configure --disable-anon --disable-ntlm --enable-sql --with-pgsql=/usr/local/pgsql --disable-java --enable-macos-framework
make
make install
There is one small bug I ran into, not sure why its not fixed. But, compiling complained about a redifinition of global_callbacks. So I edited lib/client.c around line 61, removed “static”. And edited lib/server.c, added extern to the definition of global_callbacks. That did it.
Now, back to Postfix, rebuild with the following configure command
make tidy
make -f Makefile.init makefiles 'CCARGS=-DHAS_PGSQL -I /usr/local/pgsql/include -DUSE_SASL_AUTH -I/usr/local/include/sasl -DUSE_TLS' 'AUXLIBS=-L/usr/local/pgsql/lib -L/usr/local/lib -lpq -lsasl2 -lssl -lcrypto'
make
make install
Next, I moved /usr/lib/sasl2 to /usr/lib/sasl2.old for backup. Then I symlinked /usr/local/lib/sasl2 to /usr/lib/sasl2. Switcharoo!
Now, this is fun, for you this is different, but since I have a virtual domain setup for my mail, here is my /usr/local/lib/sasl2/smtpd.conf
pwcheck_method: auxprop
mech_list: plain login cram-md5 digest-md5
auxprop_plugin: sql
password_format: crypt
sql_engine: pgsql
sql_hostnames: localhost
sql_user: my_db_username
sql_passwd: my_db_password
sql_database: my_mail_db
sql_select: select password from mailusers where username = '%u' and domain = '%r'
Here is what I added to /etc/postfix/main.cf to enable sasl, remember, I’m using the modified main.cf file that came with OSX.
smtpd_sasl_auth_enable = yes
smtpd_tls_CAfile = /etc/ssl/postfix/server.pem
smtpd_tls_cert_file = /etc/ssl/certs/dovecot.pem
smtpd_tls_key_file = /etc/ssl/private/dovecot.pem
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
This all didn’t work very well, I kept getting somethnig in the log like “cannot load Certificate Authority data”. So I knew the problem was in the smtpd_tls_CAfile area. I just went and get the server.pem file for a working gentoo box and it worked