我正在尝试使用 Postfix、Docecot 和 Roundcube 在 CentOS 上运行 Web 邮件服务器。每当我尝试向服务器发送邮件或发送测试电子邮件时,它都会失败。我可以登录,所以看起来 Dovecot 没问题。
这是我的服务器日志:
Jul 2 14:01:42 phantastyc postfix/smtpd[20154]: warning: SASL: Connect to private/auth failed: No such file or directory
Jul 2 14:01:42 phantastyc postfix/smtpd[20154]: fatal: no SASL authentication mechanisms
Jul 2 14:01:43 phantastyc postfix/master[18459]: warning: process /usr/libexec/postfix/smtpd pid 20154 exit status 1
Jul 2 14:01:43 phantastyc postfix/master[18459]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling
当我向服务器发送测试电子邮件时:
Jul 2 14:01:42 phantastyc postfix/smtpd[20154]: connect from mail-ve0-f178.google.com[209.85.128.178]
然后它显示与上面相同的错误。
当我使用 Roundcube 撰写邮件时,它只是挂起,Sending message...
过了一会儿SMTP Error (-1): Connection to server failed
,日志中又显示相同的消息。
这是我的postconf -n
输出:
alias_database = $alias_maps
alias_maps = hash:/etc/postfix/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = all
inet_protocols = ipv4
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
relay_domains = *
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_sasl_type = dovecot
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
smtpd_sasl_type = dovecot
unknown_local_recipient_reject_code = 550
virtual_alias_maps = hash:/etc/postfix/vmail_aliases
virtual_gid_maps = static:2222
virtual_mailbox_base = /var/vmail
virtual_mailbox_domains = hash:/etc/postfix/vmail_domains
virtual_mailbox_maps = hash:/etc/postfix/vmail_mailbox
virtual_minimum_uid = 2222
virtual_transport = virtual
virtual_uid_maps = static:2222
输出如下doveconf -n
:
# 2.0.9: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-042stab088.4 i686 CentOS release 6.5 (Final) reiserfs
auth_mechanisms = plain login
default_login_user = vmail
disable_plaintext_auth = no
first_valid_gid = 2222
first_valid_uid = 2222
listen = *
mail_access_groups = vmail
mail_location = maildir:/var/vmail/%d/%n
passdb {
args = scheme=SHA1 /etc/dovecot/passwd
driver = passwd-file
}
protocols = imap lmtp
service auth {
unix_listener auth-client {
group = vmail
mode = 0660
user = vmail
}
unix_listener auth-master {
group = vmail
mode = 0660
user = vmail
}
user = root
}
service imap-login {
process_min_avail = 1
user = vmail
}
ssl = no
userdb {
args = uid=2222 gid=2222 home=/var/vmail/%d/%n allow_all_users=yes
driver = static
}
当我这样做的时候:
[root@phantastyc ~]# ls -l /var/spool/postfix/private/auth
ls: cannot access /var/spool/postfix/private/auth: No such file or directory
编辑1
这种方法似乎有效,但现在出现了一条新的错误消息:
Jul 3 03:03:14 phantastyc postfix/trivial-rewrite[23348]: fatal: open database /etc/postfix/vmail_domains.db: No such file or directory
Jul 3 03:03:15 phantastyc postfix/master[18459]: warning: process /usr/libexec/postfix/trivial-rewrite pid 23348 exit status 1
Jul 3 03:03:15 phantastyc postfix/master[18459]: warning: /usr/libexec/postfix/trivial-rewrite: bad command startup -- throttling
此外,Google(我发送测试电子邮件的服务器)返回延迟错误,提示与服务器的连接已断开,将继续重试。
编辑2
使用 修复上述问题后postmap
,我遇到了另一个问题。
以下是一些日志记录:
Jul 4 21:51:20 phantastyc postfix/smtpd[13016]: connect from mail-vc0-f171.google.com[209.85.220.171]
Jul 4 21:51:21 phantastyc postfix/trivial-rewrite[13019]: warning: do not list domain phantastyc.tk in BOTH mydestination and virtual_mailbox_domains
Jul 4 21:51:21 phantastyc postfix/smtpd[13016]: NOQUEUE: reject: RCPT from mail-vc0-f171.google.com[209.85.220.171]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail-vc0-f171.google.com>
Jul 4 21:51:21 phantastyc postfix/smtpd[13016]: disconnect from mail-vc0-f171.google.com[209.85.220.171]
不在本地表中?
这是/etc/postfix/vmail_domains
:
[email protected] phantastyc.tk/admin
[email protected] phantastyc.tk/bnguyen
[email protected] oa2019.tk/admin
[email protected] oa2019.tk/bnguyen
我还搞砸了什么事?
编辑3
由于日志说我不能同时使用域名mydestination
,所以virtual_mailbox_domains
我从字段中删除了它mydestination
,现在发送邮件没问题了。 收到的邮件仍然有点不稳定。
Jul 4 22:10:41 phantastyc postfix/smtpd[13160]: connect from mail-vc0-f173.google.com[209.85.220.173]
Jul 4 22:10:41 phantastyc postfix/smtpd[13160]: 514F213E0E3A: client=mail-vc0-f173.google.com[209.85.220.173]
Jul 4 22:10:41 phantastyc postfix/cleanup[13164]: 514F213E0E3A: message-id=<CADZik+X9uC8QGJZtNoWKk_Aw0bdCP49DUVgdWkhVBCZVOuz3cg@mail.gmail.com>
Jul 4 22:10:41 phantastyc postfix/qmgr[13153]: 514F213E0E3A: from=<[email protected]>, size=1930, nrcpt=1 (queue active)
Jul 4 22:10:41 phantastyc postfix/virtual[13165]: 514F213E0E3A: to=<[email protected]>, relay=virtual, delay=0.4, delays=0.32/0.01/0/0.06, dsn=4.2.0, status=deferred (delivery failed to mailbox /var/vmail/phantastyc.tk/admin: cannot open file: Is a directory)
Jul 4 22:10:41 phantastyc postfix/smtpd[13160]: disconnect from mail-vc0-f173.google.com[209.85.220.173]
Jul 4 22:11:08 phantastyc postfix/smtpd[13160]: connect from localhost.localdomain[127.0.0.1]
Jul 4 22:11:08 phantastyc postfix/smtpd[13160]: 4292A13E0E3B: client=localhost.localdomain[127.0.0.1], sasl_method=LOGIN, [email protected]
这让我很害怕:
(delivery failed to mailbox /var/vmail/phantastyc.tk/admin: cannot open file: Is a directory)
那是怎么回事?
这是ls /var/vmail/phantastyc.tk/admin
:
cur
dovecot.index.log
dovecot.mailbox.log
dovecot.uidlist
dovecot.uidvalidity
dovecot.uidvalidity.53b3965c
new
subscriptions
tmp
这是/etc/postfix/vmail_domains
:
[email protected] phantastyc.tk/admin
[email protected] phantastyc.tk/bnguyen
[email protected] oa2019.tk/admin
[email protected] oa2019.tk/bnguyen
编辑4
抱歉,我操之过急。我应该先做这件事。简单搜索后发现邮箱目录中缺少一个尾部斜杠。我的邮件服务器现在运行正常。
答案1
看起来 dovecot 配置和 postfix 配置不匹配。
在鸽舍配置中(特别是在第服务认证,你只需定义两个套接字 身份验证客户端和授权主控. 添加一个unix_listener
包含内容的部分
unix_listener /var/spool/postfix/private/auth {
mode = 0660
# Assuming the default Postfix user and group
user = postfix
group = postfix
}
看这一页以获取进一步的文档。