Postfix 中继 ldap 查找和传输

Postfix 中继 ldap 查找和传输

我正在尝试实现 postfix + policyd/amavis + dspam。问题是我需要进行 ldap 查找才能获得下一跳。但同时我需要将一些“电子邮件地址”重定向到“dspam-retrain”。我不知道该怎么做,我的意思是,我的配置如下:

主配置文件

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
mydomain = ddol-test.com
myorigin = $myhostname
inet_interfaces = localhost, 192.168.66.98
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = 192.168.66.0/24, 127.0.0.0/8
relay_domains = $mydestination
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

#transport_maps = ldap:/etc/postfix/perditionMailhost_ldap
transport_maps = hash:/etc/postfix/transport
content_filter = amavisd-new:[127.0.0.1]:10024

debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
local_recipient_maps =

主配置文件

smtp      inet  n       -       n       -       200       smtpd -v
pickup    fifo  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       n       -       -       smtp
relay     unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
        -o disable_dns_lookups=yes
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
amavisd-new unix      -      -             n      -    2       smtp
        -o smtp_data_done_timeout=1200s
        -o disable_dns_lookups=yes
127.0.0.1:10025      inet  n       -       n       -       -       smtpd
        -o content_filter=lmtp:unix:/tmp/dspam.sock
        -o dspam_destination_recipient_limit=1
localhost:10026 inet  n -       n       -       -        smtpd
  -o content_filter=
  -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
  -o smtpd_helo_restrictions=
  -o smtpd_client_restrictions=
  -o smtpd_sender_restrictions=
  -o smtpd_recipient_restrictions=permit_mynetworks,reject
  -o mynetworks=127.0.0.0/8
  -o smtpd_authorized_xforward_hosts=127.0.0.0/8
dspam-retrain   unix    -       n       n       -       10      pipe
 flags=Ru user=dspam argv=/usr/bin/dspam --user [email protected] --class=$nexthop --source=error

猫/等/后缀/运输

[email protected]    dspam-retrain:spam
[email protected]     dspam-retrain:innocent
[email protected]     dspam-retrain:innocent

cat /etc/postfix/perditionMailhost_ldap

server_host = ldap1-1.ddol-test.com:1389
version = 3
search_base = ou=mymensajes,ou=pre_ddolcontext,dc=org
scope = sub
query_filter = mail=%s
result_attribute = perditionMailhost
ldap_bind = no
result_filter = relay:[%s]

因此,我需要:

如果邮件[电子邮件保护]重定向到 dspam-retrain:spam,否则使用 ldap 表获取下一跳。

但我不知道应该使用哪个额外选项,因为我不能使用两个 transport_maps 定义。

我不确定我是否正确解释自己,我希望如此:)

谢谢!

答案1

您不能使用多个定义,但您可以根据需要将任意transport_maps数量的数据源列为一个。因此,transport_maps

transport_maps = hash:/etc/postfix/transport ldap:perdition

应该可以。只需在所有/etc/postfix/perditionMailhost_ldap定义前加上单词前缀perdition,例如

perdition_server_host = ldap1-1.ddol-test.com:1389
perdition_version = 3
perdition_search_base = ou=mymensajes,ou=pre_ddolcontext,dc=org
(and so on)

此外,您的 query_filter 很可能是perdition_query_filter = (mail=%s),LDAP 对括号很挑剔。

相关内容