Authentication problems with postfix, courier, mysql and virtual domains

Submit to reddit

I outgrew my shared hosting and decided to go for a dedicated virtual server. I chose Linode but I will leave that for another article.

I decided to use postfix + courier + mysql and virtual domains for my mail setup. Everythig was configured fine and dandy according to the documentation. But I kept getting this in the logs:

Mar  6 13:54:42  saslauthd [5734]: pam_mysql - required option "db" is not set Mar  6 13:54:42  saslauthd [5734]: DEBUG: auth_pam: pam_authenticate failed: Error in service module
Mar  6 13:54:42  saslauthd [5734]: do_auth : auth failure: [] [service=smtp] [] [mech=pam] [reason=PAM auth error]

I went over the config files over and over again searching for mistakes, because I usually mix something up but nothing worked. After some time I realized that the error “db” not set is more important than I thought. It meant that it’s not about wrong passwords copied from examples.

Well, the problem was that in /etc/pam.d/smtp  the password for the mysql user cannot contain the # character. And my password had. I have used a random password generator and by luck it contained a #. Everything after that was ignored, that’s why it said db not set. That’s a lost hour for nothing. Everywhere elese in the many config files containing this password it’s ok to have a # but not here.