[cc lang="bash"]
\$ apt-get install libsasl2-2 libsasl2-modules libsasl2-modules-sql
sasl2-bin libpam-mysql
\$ mkdir -p /var/spool/postfix/var/run/saslauthd
\$ vi /etc/default/saslauthd
\$ vi /etc/pam.d/smtp
\$ vi /etc/postfix/sasl/smtpd.conf
\$ adduser postfix sasl
\$ /etc/init.d/postfix restart
\$ /etc/init.d/saslauthd restart
[/cc]
/etc/default/saslauthd
[cc lang='bash']
START=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="pam"
MECH_OPTIONS=""
THREADS=0
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"
[/cc]
/etc/pam.d/smtp
[cc lang='bash']
auth required pam_mysql.so user=mail passwd=XXX host=127.0.0.1 db=mail
table=users usercolumn=email passwdcolumn=password crypt=1
account sufficient pam_mysql.so user=mail passwd=XXX host=127.0.0.1
db=mail table=users usercolumn=email passwdcolumn=password crypt=1
[/cc]
/etc/postfix/sasl/smtpd.conf
[cc lang='bash']
pwcheck_method: saslauthd
mech_list: plain login
allow_plaintext: true
auxprop_plugin: mysql
#auxprop_plugin: sql - debian Wheezy
#sql_engine: mysql - debian Wheezy
sql_hostnames: 127.0.0.1
sql_user: mail
sql_passwd: XXX
sql_database: mail
sql_select: select password from users where email = '%u'
#sql_select: select password from users where email = '%u@%r' -
debian Wheezy
[/cc]