Installation of Exim4 as mail server for IMAP and POP3 protocol. The SMTP is routed through another SMTP service provider.
Usually Exim4. We want secure authentication, viruses checking and all, so :
tchetch@debian# aptitude install exim4 exim4-daemon-heavy
tchetch@debian# dpkg-reconfigure exim4-config
To configure domain list via LDAP lookup. Each of our domain we have are specified as associateddomain in o=iro.
dn: o=iro objectclass: organization objectclass: domainrelatedobject o: iro associateddomain: irovision.ch associateddomain: iro.vsnet.ch
So if a mail is for one of those domains, we want to handle the mail else we route to another smtp server. To do so we have in our file /etc/exim4/exim4.conf.template (Commented part comes from original Debian configuration (with two #)) :
# TCHETCH MOD
##.ifndef MAIN_LOCAL_DOMAINS
##MAIN_LOCAL_DOMAINS = DEBCONFlocal_domainsDEBCONF
##.endif
##domainlist local_domains = MAIN_LOCAL_DOMAINS
# We search for associateddomain, but the answere will be "irovision.ch, iro.vsnet.ch".
# We replace ',' by ':' to get "irovision.ch: iro.vsnet.ch" with ${sg {subject}{regex}{replacement}} !
domainlist local_domains = ${sg { ${lookup ldap{ \
ldap://debian/o=iro?associateddomain?base?}}}{,}{:}}
As we want only LDAP user to be routed (no system user), we need a new router. We remove local_user router and add a ldap_user. The matching is done on mail attribute, we get the local part (before @) and compare it to the given local part :
LDAP_USER_INFO = ${lookup ldap{\
ldap://siro5.iro/ou=Users,o=iro?mail,homedirectory,uidnumber,gidnumber?sub?(mail=${quote_ldap:$local_part@$domain})}}
LDAP_USER_EMAIL = ${extract {mail}{LDAP_USER_INFO}}
LDAP_USER_HOME = ${extract {homedirectory}{LDAP_USER_INFO}}
LDAP_USER_UID = ${extract {uidnumber}{LDAP_USER_INFO}}
LDAP_USER_GID = ${extract {gidnumber}{LDAP_USER_INFO}}
ldap_user:
debug_print = "R: ldap_user for $local_part@$domain"
driver = accept
local_parts = ${local_part: ${extract {1}{,}{LDAP_USER_EMAIL}}}
router_home_directory = ${extract {1}{,}{LDAP_USER_HOME}}
user = ${extract {1}{,}{LDAP_USER_UID}}
group = ${extract {1}{,}{LDAP_USER_GID}}
transport = LOCAL_DELIVERY
cannot_route_message = Unknown user
# REMOVE local_user from original configuration
#
#local_user:
# debug_print = "R: local_user for $local_part@$domain"
# driver = accept
# domains = +local_domains
# check_local_user
# local_parts = ! root
# transport = LOCAL_DELIVERY
# cannot_route_message = Unknown user
By default maildir format store all its data in $home/Maildir. As our home directory are avaible on Windows, we want to hide thoses file. We just want to have our data in $home/.maildir. This happens in maildir_home transport :
maildir_home: debug_print = "T: maildir_home for $local_part@$domain" driver = appendfile # TCHETCH MOD ## .ifdef MAILDIR_HOME_MAILDIR_LOCATION ## directory = MAILDIR_HOME_MAILDIR_LOCATION ## .else directory = $home/.maildir ## .endif