后缀。限制。发送邮件 from/to 指定 table

Postfix. Restrictions. Send mail from/to specified table

我有 ldap table 登录

ldapsearch -x -h ldap.server-b 'ou=mail,ou=Groups,dc=my,dc=org' '(&(cn=mailFullAccess)(memberUid=username))'

输出

dn: cn=mailFullAccess,ou=mail,ou=Groups,dc=my,dc=org
gidNumber: 5555
memberUid: fred
memberUid: bob
memberUid: username
cn: mailFullAccess

创建 LDAP table

search_base = ou=mail,ou=Groups,dc=my,dc=org
server_host = ldap.server
query_filter = (&(cn=mailFullAccess)(memberUid=%u))
result_attribute = memberUid
result_format = %u      internal_hosts_class
scope = sub
bind = yes

尝试用命令检查

postmap -q username ldap:./mailFullAccess_check.cf

产生结果

fred    internal_hosts_class, bob internal_hosts_class, username internal_hosts_class

找到 1 个匹配项。

和本地域文件列表(local_urls.db)

mydomain1.ru      OK
mydomain2.ru       OK
mydomain3.ru    OK

我想要,'username' 只能向本地域发送电子邮件

我写在main.cf。 SMTP 身份验证(来自 LDAP 的 saslauthd)工作正常。

...
smtpd_recipient_restrictions =
        permit_sasl_authenticated
        reject
...
smtpd_restriction_classes = internal_hosts_class
internal_hosts_class =   check_recipient_access hash:/etc/postfix/border/local_urls, reject
smtpd_sender_restrictions = check_sender_access  ldap:/etc/postfix/border/mailFullAccess_check.cf
...

postfix 重启,发送邮件出现错误

Feb  3 11:30:53 email postfix/smtpd[10546]: warning: unknown smtpd restriction: "fred"

你的 postmap 命令

postmap -q username ldap:./mailFullAccess_check.cf

应该只是returninternal_hosts_class字符串。这就是为什么 postfix 抱怨错误 unknown smtpd restriction.

解决方案已修改 mailFullAccess_check.cf 尤其是 result_format 变为

result_format = internal_hosts_class