Postfix SMTP auth不能与虚拟邮箱+ SASL + Courier userdb一起使用

所以我已经阅读了各种教程和方法,我正在努力弄清楚如何在Postfix中使用虚拟邮箱进行SMTPauthentication。 我使用这个Ubuntu教程来设置。 我正在使用Courier-IMAP和POP3阅读邮件,似乎没有问题。

但是,用于读取邮箱的凭据不适用于SMTP。 我可以从/var/log/auth.log中看到正在使用PAM,这是否需要UNIX用户帐户才能工作? 正如我使用虚拟邮箱来避免创build用户帐户。

 li305-246 saslauthd[22856]: DEBUG: auth_pam: pam_authenticate failed: Authentication failure li305-246 saslauthd[22856]: do_auth : auth failure: [user=fred] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error] 

/var/log/mail.log

 li305-246 postfix/smtpd[27091]: setting up TLS connection from mail-pb0-f43.google.com[209.85.160.43] li305-246 postfix/smtpd[27091]: Anonymous TLS connection established from mail-pb0-f43.google.com[209.85.160.43]: TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits) li305-246 postfix/smtpd[27091]: warning: SASL authentication failure: Password verification failed li305-246 postfix/smtpd[27091]: warning: mail-pb0-f43.google.com[209.85.160.43]: SASL PLAIN authentication failed: authentication failure 

根据本教程,我在userdb中创build了帐户。 Postfix也使用authuserdb吗?

需要哪些debugging信息来帮助诊断我的问题?

main.cf:

 # TLS parameters smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt smtpd_tls_key_file = /etc/ssl/private/smtpd.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # SMTP parameters smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtp_tls_security_level = may smtpd_tls_security_level = may smtpd_tls_auth_only = no smtp_tls_note_starttls_offer = yes smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom 

/etc/postfix/sasl/smtpd.conf

 pwcheck_method: saslauthd mech_list: plain login 

/etc/default/saslauthd

 START=yes PWDIR="/var/spool/postfix/var/run/saslauthd" PARAMS="-m ${PWDIR}" PIDFILE="${PWDIR}/saslauthd.pid" DESC="SASL Authentication Daemon" NAME="saslauthd" MECHANISMS="pam" MECH_OPTIONS="" THREADS=5 OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd" 

/etc/courier/authdaemonrc

 authmodulelist="authuserdb" 

我只修改authdaemonrc一行,并按照本教程重新启动服务。 我已经通过userdbuserdbpw将帐户添加到/etc/courier/userdb ,并根据教程运行makeuserdb

解决了

感谢Jenny Dbuild议使用rimap对localhost IMAP服务器(读取userdb证书)进行身份validation。

我更新了/etc/default/saslauthd来正确启动saslauthd( 这个页面很有用)

 MECHANISMS="rimap" MECH_OPTIONS="localhost" THREADS=0 OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r" 

这样做后,我在/var/log/auth.log得到以下错误:

 li305-246 saslauthd[28093]: auth_rimap: unexpected response to auth request: * BYE [ALERT] Fatal error: Account's mailbox directory is not owned by the correct uid or gid: li305-246 saslauthd[28093]: do_auth : auth failure: [user=fred] [service=smtp] [realm=] [mech=rimap] [reason=[ALERT] Unexpected response from remote authentication server] 

此博客文章详细介绍了在/etc/courier/imapd设置IMAP_MAILBOX_SANITY_CHECK=0的解决scheme。

然后重新启动您的信使和saslauthd守护程序,以使configuration更改生效。

 sudo /etc/init.d/courier-imap restart sudo /etc/init.d/courier-authdaemon restart sudo /etc/init.d/saslauthd restart 

在尝试发送电子邮件时观看/var/log/auth.log 。 希望你好!

这实际上比Postfix问题更重要。 你已经把postfix设置成与sasl交谈了 – 到目前为止,这么好。 现在你需要告诉saslauthd在哪里可以find你的用户名和密码。 如果你不给它任何参数,它将默认把它们视为本地用户,这是你在auth.log中看到的。

据我所知(对于SASL来说可能并不是很远),它并不使用与pop3虚拟用户相同的数据库。 但是,saslauthd有一个select,可以尝试使用相同的凭据loginIMAP服务器 – 我应该按照自己的意愿进行操作。

要做到这一点,你开始像这样saslauthd:

 saslauthd -a rimap -O myimap.server.com 

您应该能够使用程序testsaslauthd来testing身份validation,这应该与您的sasl安装一起提供。 祝你好运!