dovecot-sql.conf

driver = mysql
connect = host=127.0.0.1 dbname=mail_server user=mail_user password=mail_password
default_pass_scheme = PLAIN-MD5
password_query = SELECT email as user, password FROM view_users WHERE email='%u';