SASL Authentication with Postfix and MySQL
From FrugalWiki
Contents |
Introduction
I assume you have alread created the mysql tables and filled out them with a sample data, described here.
SASL2 Installation
Fairly simple. A
pacman -S cyrus-sasl cyrus-sasl-sql saslauthd
should do the trick.
SASL2 Configuration
Postfix's main.cf
Add the followings to your /etc/postfix/main.cf:
broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauth_destination, reject_unauth_pipelining, reject_invalid_hostname, reject_rbl_client opm.blitzed.org, reject_rbl_client list.dsbl.org, reject_rbl_client bl.spamcop.net, reject_rbl_client sbl-xbl.spamhaus.org smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous
This also contains examples to block some spam. More info about this here or here.
smtpd.conf
Your /usr/lib/sasl2/smtpd.conf should contain something like this:
pwcheck_method: auxprop auxprop_plugin: sql mech_list: plain login log_level:9 sql_engine: mysql sql_hostnames: 127.0.0.1 sql_user: postfix sql_passwd: postfix sql_database: postfix sql_select: select password from mailbox where username='%u@%r'
You probably want to change the values of the sql_user and sql_passwd fields. Also if everything works well, you may want to decrease the value of log_level.
Testing
That's all, now you should be able to use this machine as an smtp server using your full email address as a username and your password (defined above) as password.