Re: [exim] Mailing list in Exim

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Rafał Kupka
Data:  
Para: exim-users
Asunto: Re: [exim] Mailing list in Exim
On Fri, Aug 15, 2008 at 05:12:15PM +0400, Артем Каялайнен wrote:
Hi,

> ... My problem is
> that i want to create mailing list. Example: in active directory i
> have a group "IT" with mail atribute "it@???". This group
> include four users. When i send mail to it@??? this mail must
> be delivered to four users, which are included in group "IT"


You can use exim for small mailing lists (more like multi-recipient
e-mail aliases). If there is more members you should look at some
full-feature mailing list managers (for example mailman). IMHO.

> From exim docs i learn that router "redirect" may solve this problem.
> If i substitute in data field all needed e-mail - router sends mail to
> new mails. Right? Or it's wrong?
> Problem is that i can't get e-mail in one ldap query, which i need to
> substitue in data field in router config.
>
> My ldap query:
>
> ${lookup ldapm{user=CN=ldap%20ldap,CN=Users,DC=example,DC=com
> pass=12345678 ldap:///dc=example,dc=com
> ?member?sub?(&(mail=${quote_ldap:it}${quote_ldap:@}${quote_ldap:example.com
> }))}{$value}}
>
> and in returns me all distinguished names of users (And this names
> include spaces )-: ).


> But I don't know how to get e-mail field from ldap when i have a set
> of distinguished names. Can anyone explain me how to fix this problem
> with mailing list, created dynamically from active directory data? Or
> maybe exists other solution?


Try something like this:
LDAP_BASE=dc=example,dc=com
LDAP_CRED=user="CN=ldap%20ldap,CN=Users,LDAP_BASE" pass=12345678
LDAP_FILT=(&(mail=${quote_ldap:it}${quote_ldap:@}${quote_ldap:example.com}))

${sg{
${map
  {<\n ${sg{${lookup ldapm
               {LDAP_CRED ldap:///LDAP_BASE?member?sub?LDAP_FILT}
             }
           }{\N, \N}{\n}
        }
  }
  {${lookup ldap{LDAP_CRED ldap:///${quote_ldapdn:$item}?mail?base?}}}
 }
}{\N\n\N}{, }}


I'll try to explain this:
The most inner lookup is your ldap query returning DN of list members.
That next ${sg is in expression because ldapm returns data in format:

atribute1_object1, atribute2_object1, atrubite3_object1<new line>
atribute1_object2<new line>
atribute1_object3<new line>

It's needed for object1 in example above (to change ", " into new line).
I don't know if there are such object in your AD, but let's handle them
properly.

${map[1] take that data (one DN per line) and does LDAP query to get email
address from DN of user.

The most outer ${sg make comma separated list from multiple lines.

It's only lightly tested[2] but should work well.
But it's quote inefficient -- one additional ldap query per recipient.

Exim string mangling is explained in chapter 11 of exim spec.
http://www.exim.org/exim-html-current/doc/html/spec_html/ch11.html

Regards,
Kupson
[1] For ${map you need quite a new exim version (4.67?).
[2] Only by exim -be, I don't try exim router with it.
--
Great software without the knowledge to run it is pretty useless.
(Linux Gazette #1)