Postfix and Ldap (Forward and Redirect)

Skip to first unread message


Jul 11, 2007, 7:02:59 AM7/11/07

I'm planning a mail server setup based on Postfix and Ldap (Courier
Pop/Imap) plus Amavis, and i would like to keep all user information
into the ldap (no .forward files).

I've setup a test server and working on it. Now i'm stuked and i need
some help :)

Ldap schema is mainly based on the authldap.schema and is like this:
(May change if needed)

mail: us...@our.domain
maildrop: nick...@our.domain
localdelivery: true / false
accountStatus: active

What i need to do is let the user forward mail to an external account
and if localdelivery is set to true also drop mail into local mailbox,
if localdelivery is set fo false only deliver mail to the external

Before amavis alias map query_filter is something like this:


so amavis rules always refer to the "mail:" address.

After amavis process message this is returned to smtp on port 10025 and
here i need to further process the message:

What i need is a query filter to return mail AND mailForwardingAddress
if localdelivery is true, and just mailForwardingAdress if
localdelivery is false.

I've thinked a lot but i've found no solution. The only things that
comes me to mind is to set up TWO query_filter like this:
The first filter return "mail:" if localdelivery is true
The second filter reurn "mailForwardingAddress:" if present

This way however i'm going to make two ldap lookups (3 with pre-amavis
one) for single message delivery. Is there a smarter way to do
something like this?




Jul 11, 2007, 7:54:02 AM7/11/07
Hi Mio,

I had troubles with the same situation than you. What I did was to create in the following:

virtual_alias_maps = proxy:ldap:/etc/postfix/bancos/

bind = yes
server_host = ldap://
search_base = dc=DOMAIN
version = 3
bind_dn = cn=linuxbind,dc=DOMAIN
bind_pw = secret
scope = sub
query_filter = (&(&(objectClass=user)(maildrop=%s))
result_attribute = mailforward

I don't use openldap here, i use Active Directory. This attribute mailforward is
multivalued and let you put more than one email address.

For example:

mailforward: watashi@gmail
mailforward: watashi@domain

Why maildrop and mail is equal?? Because I use maildrop here too, and it look
for users in mail attribute. If there are two mail attribute with the same
content, it gives error, so I had to make it. It works perfect to me!! This
schema above send a email to and one email for the own

So, when the email arrives, postfix look for email as alias, and after that, as
local users(ldap). To works with redirect and forward, the destination has to
be a alias unfortunally.








Para fazer uma ligação DDD pra perto ou pra longe, faz um 21. A Embratel tem
tarifas muito baratas esperando por você. Aproveite!

Reply all
Reply to author
0 new messages