You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Postfix转发邮件至Dovecot时出现「User doesn't exist」错误的排查求助

Postfix转发邮件至Dovecot时出现「User doesn't exist」错误的排查求助

大家好,我碰到了一个棘手的问题:Postfix明明能通过LDAP查到用户,但转发邮件到Dovecot时却被返回「User doesn't exist」的错误,想请各位帮我分析一下原因。

先说说我的环境:

  • Postfix服务器通过LMTP协议把所有邮件转发到Dovecot服务器(地址是192.168.50.223:10025)
  • 用户账号和组信息都存在389-Directory Server(LDAP)里

我的Postfix配置

/etc/postfix/transport 文件(每个托管域名一行):

mydomain.com                   lmtp:inet:[192.168.50.223]:10025

/etc/postfix/main.cf 关键配置:

relay_recipient_maps = proxy:ldap:/etc/postfix/ldap-users-389.cf
...
virtual_alias_maps = ldap:/etc/postfix/ldap-groups-389.cf
...
transport_maps = hash:/etc/postfix/transport

/etc/postfix/ldap-users-389.cf(LDAP用户查询配置):

server_host = ds
search_base = ou=people,dc=adomaine,dc=tld
version = 3
query_filter = (&(objectClass=nsPerson)(|(mail=%s)(mailAlternateAddress=%s)))
result_attribute = mail
#result_filter = OK
bind = yes
bind_dn = cn=Directory Manager
bind_pw = XXXXXXXXXX

/etc/postfix/ldap-groups-389.cf(LDAP组查询配置):

server_host = ds
search_base = ou=groups,dc=adomain,dc=tld
version = 3
query_filter = (&(objectClass=mailgroup)(|(mail=%s)(mail=%d)))
leaf_result_attribute = mail
special_result_attribute = uniqueMember
bind = yes
bind_dn = cn=Directory Manager
bind_pw = XXXXXXXX

LDAP中的用户信息

我在LDAP里创建了一个用户条目:

dn=cn=myname,ou=people,dc=yellowgnu,dc=net

包含的属性:

objectClass top
objectClass nsPerson
objectClass nsAccount
objectClass nsOrgPerson
objectClass posixAccount
objectClass mailrecipient
cn  myname
mail    myname@adomain.tld
mailAlternateAddress    myname@seconddomain.tld

错误日志

Postfix服务器的/var/log/maillog里的错误记录:

May 7 18:33:54 mx postfix/lmtp[16088]: D29FE60E5173: to=myname@seconddomain.tld, relay=192.168.50.223[192.168.50.223]:10025, delay=39, delays=33/0.01/0.01/5.9, dsn=5.1.1, status=bounced (host 192.168.50.223[192.168.50.223] said: 550 5.1.1 myname@seconddomain.tld User doesn't exist: myname@seconddomain.tld (in reply to RCPT TO command))

LDAP服务器的日志显示查询成功:

[07/May/2023:18:33:34.962281900 +0300] conn=235 op=21 SRCH base="ou=people,dc=adomain,dc=tld" scope=2 filter="(&(objectClass=nsPerson)(|(mail=myname@seconddomain.tld)(mailAlternateAddress=myname@seconddomain.tld)))" attrs="mail"
[07/May/2023:18:33:36.665394512 +0300] conn=235 op=21 ENTRY dn="cn=myname,ou=people,dc=adomaine,dc=tld"
[07/May/2023:18:33:36.866690132 +0300] conn=235 op=21 RESULT err=0 tag=101 nentries=1 wtime=1.014704138 optime=1.951879611 etime=2.966580180

测试结果

我在Postfix服务器上执行查询命令,能正确返回用户的主邮箱地址:

# postmap -q myname@seconddomain.tld ldap:/etc/postfix/ldap-users-389.cf
myname@adomain.tld

明明Postfix能查到用户的主邮箱,但转发给Dovecot的时候还是用别名地址发送,导致Dovecot找不到用户。有没有大佬知道问题出在哪?麻烦帮忙指点一下,谢谢!

备注:内容来源于stack exchange,提问作者alini76

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 12:43:01