Now the tricky part, I'd spent hours on this. Postfix does a chroot, so it cant communicate with saslauthd, you need to run the following:
rm -r /var/run/saslauthd/
mkdir -p /var/spool/postfix/var/run/saslauthd
ln -s /var/spool/postfix/var/run/saslauthd /var/run
chgrp sasl /var/spool/postfix/var/run/saslauthd
adduser postfix sasl
I also did the following, don't know if it affect it or not:
chmod o+r /etc/sasldb2
Restart postfix and saslauthd:
/etc/init.d/postfix restart
/etc/init.d/saslauthd start
I also changed the password for the test account, so it may updated saslauthd
passwd username
Now generate the base64 string for testing:
perl -MMIME::Base64 -e 'print encode_base64("username\0username\0password")'
Let's test the SMTP auth now:
telnet localhost 25
auth plain dXNlcm5hbWUAdXNlcm5hbWUAcGFzc3dvcmQ=
Here's the following output as example:
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
auth plain dXNlcm5hbWUAdXNlcm5hbWUAcGFzc3dvcmQ=
235 2.7.0 Authentication successful