0

I'm trying to implement postfix + policyd/amavis + dspam. The problem is that I need to do ldap lookups in order to obtain the nexthop. But at the same time I need to redirect some "email address" to "dspam-retrain". I don't know how to do it, I mean, my config is the following:

main.cf

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 =

master.cf

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 mgimeno@pre.ddol.es --class=$nexthop --source=error

cat /etc/postfix/transport

spam@pre.ddol.es    dspam-retrain:spam
ham@pre.ddol.es     dspam-retrain:innocent
notspam@pre.ddol.es     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]

So, I need:

if mail is spam@pre.ddol.es redirect to dspam-retrain:spam else use ldap table to obtain the nexthop.

But I don't know which extra option I should use, because I cannot use two transport_maps definition.

I'm not sure if I explain my self correctly, I hope so :)

Thanks!

magiza83
  • 83
  • 2
  • 10

1 Answers1

2

You can't use several transport_maps definitions, but you can list as many data sources to one transport_maps as you like. So,

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

should work. Just prefix all your /etc/postfix/perditionMailhost_ldap definitions with the word perdition, like

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)

Also your query_filter will most likely be perdition_query_filter = (mail=%s), LDAP is picky about parenthesis.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • thanks! it works, but instead of use "perdition" prefix I use the full path for ldap: {transport_maps= hash:/etc/postfix/transport ldap:/etc/postfix/perditionMailhost_ldap} Anyway, thanks a lot for the answer, it has been very helpful! – magiza83 May 25 '12 at 09:56
  • Glad I was able to help :) – Janne Pikkarainen May 25 '12 at 10:03