The Exim MTA reads its configuration from an external file called /etc/exim.cf or /usr/local/exim/configure or some such. The file’s content is structured into sections which, among others, contain routers and transports.

These sections hold configuration directives which instruct Exim how, and in which order, to handle and process a message. The directives are written in plain English keywords and their options are sometimes quite convoluted expressions which can be carried over more than one line.

I attempt to write those expressions in such a way as that they become as easily readable as possible, using Exim macros whenever possible. An example shows what I mean. The following router searches an LDAP directory for an entry having a mail or mailAlternateAddress attribute types match the mail address iff the entry doesn’t have a type service set to “nomail”. If the search returns exactly one entry the router matches and hands the message off to the maildir transport.

ldap_default_servers    = ldap.example.net::636
BASEDN          = o=Example
USERSDN         = ou=${quote_ldap:${domain}},BASEDN
BINDDN          = cn=exim,BASEDN
BINDPW          = "secret"

ISLDAPVALID     = (!(service=nomail))
LDAP_LOCALUSER  = user=BINDDN \\
   pass=BINDPW \\
  ldaps:///USERSDN?mail?sub?\\
(&(|(mail=${quote_ldap:${local_part}}@${domain})\\
(mailAlternateAddress=${quote_ldap:${local_part}}@${domain}))\\
ISLDAPVALID)


ldapuser:
  driver        = accept
  condition     = ${lookup ldap{LDAP_LOCALUSER}}
  transport     = local_maildir

Note how the description of the router looks clear and concise. The macros get a bit long (and may look a bit weird in your browser) but all in all, I find it easier to study than having long lookup statements strewn in all over the show.

LDAP and Mail :: 02 Jan 2006 :: e-mail