The longer Christian and me (Mathias) are working on our Rails project (www.deineschokoladen.com) the more we two realize that our way of working is different. When I have a problem I sit down and start programming, whereas Christian asks google if there exists any plugin/module/snippet that solves the problem. After several month I have to admit that my way of thinking was alright when I was still working with PHP but in Rails Christians way is much more efficient. So we were thinking about the DRY (Don’t Repeat Yourself) principle and we came to the conclusion that its not only about “yourself”, as so many things are already done, it should be: DRA (Don’t Repeat Anything)
Pitfalls with postfix smpt and db auth
Now its running! a postfix with courier and sasl on my ubunto server having virtual users stored in a mysql. Regarding the tutorials you can find (e.g. this is a good one in german) it doesn’t seem to be complicated, but just a lot of work. But I had two BIG problems during configuration. Happily I managed to solve them both:
1. After setting up everything I got the error: “pam_mysql – required option “db” is not set” when trying to send mails. This was very strange as this parameter is not needed and was also not mentioned in any tutorial. After longer research using my big friend (brother?!) google, I realized that my mysql user had a password that contained a “#” which is a illigeal character! Nice error message I have to say
Somehow the “#” is a character that stops the evaluation of password string. I don’t know if other special chars are also a problem, my password it now only “normal” charecters.
2. My users all had a username like user@domain unfortunately courier does NOT support that type of username. Whenever I tried smpt from my mail client he cut of the “@domain” part and looked up the “user” in my db. One possibility would have been to switch to dovecot which “seems” to support this type of names (howto), but I didn’t want to. Also changin all my users for some different login name was not a solution as I allready had the whole structure of my mail dir like “/domain/user”. So I decided to map the “@” in my usernames to a “#”. Now my user names are like user#domain and still all the mapping to the folders “domain/user” is done. All I had to do was changing
“authmysqlrc” (for outgoing) :
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,’#',-1),’/',SUBSTRING_INDEX(email,’#',1),’/')
and “mysql-virtual-mailboxes.cf (which contains the mapping on my machine) (for incoming)
query = SELECT CONCAT(SUBSTRING_INDEX(email,’#',-1),’/',SUBSTRING_INDEX(email,’#',1),’/') FROM users WHERE email=REPLACE(’%s’,'@’,'#’)
Now it works … if all I did was bullshit and could have been done in a nicer way, please leave a comment.
Letzte Kommentare