Mysql – Postfix smtp relay with thesql autentification. How to


I have a Centos 5 mail server setup with postfix and dovecot (+ postfix admin). Dovecot autentification is trough mysql database (which is updated with postfix admin). Passwords are stored in md5.

Now my smtp server is closed relay, I want to open it for mailboxes/users I've created trough postfix admin. They should input the same username/password I've created with postfix admin to be able to send email trough my smtp server.

Where should I start?

Let me know in the comments what info you need and I'll provide it.

Best Answer

you can easily integrate postfix with dovecot sasl, and interface dovecot with MySQL. Have a look at: and

I successfully use postfix+dovecot sasl with password file authentication:

dovecot cfg:

protocols = none
listen =
first_valid_uid = 89
auth_verbose = yes
auth default {
  mechanisms = plain login
  passdb passwd-file {
    args = /etc/postfix/smtpd.auth.passwd
  userdb static {
    args = uid=89 gid=89 home=/var/mail/null/
  user = root
  count = 5
  socket listen {
    client {
      path = /var/spool/postfix/private/auth
      mode = 0660
      user = postfix
      group = postfix

part of postfix cfg:

smtpd_recipient_restrictions =

# postfix-dovecot SASL options
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
# report sasl login name in Received: message headers
smtpd_sasl_authenticated_header = yes

# TLS/SSL configuration
smtpd_tls_cert_file = /etc/postfix/ssl/server-cert.pem
smtpd_tls_key_file = /etc/postfix/ssl/server-key.pem
###cat server_cert.pem intermediate_CA.pem > server.pem
#smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_use_tls = yes