1 From: Nathan Ollerenshaw <nathan@valuecommerce.co.jp>
3 ## I've been working quite hard to come up with a config that reasonably
4 ## matches the qmail-ldap setup, without the warts. I want to submit it
5 ## for inclusion in your config.samples archive, in case anyone else needs
6 ## to do the same as I. I hope its useful.
8 ## A few notes; it supports catchalls but not dash extension addressing,
9 ## as I couldn't be bothered, and I'm unsure as to how many people
10 ## actually use the feature. Certainly nobody on my system. It supports
11 ## autoreplies, but not an autoreply on a catchall, because this just
12 ## kills your mailserver when someone does a dictionary spam attack
13 ## against a domain set up this way.
16 ######################################################################
17 # Runtime configuration file for Exim #
18 ######################################################################
20 #domainlist local_domains = @ : lsearch:/apps/conf/mail/locals
21 domainlist local_domains = lsearch;/apps/conf/mail/locals
22 domainlist relay_to_domains =
24 # the pop-before-smtp package at http://popbsmtp.sourceforge.net/
25 # creates the /etc/mail/popauth.db file for us. We have to use dbmnz
28 hostlist relay_from_hosts = 127.0.0.1 : net-dbmnz;/etc/mail/popauth.db
29 primary_hostname = [[[SET THIS TO LOCAL HOST NAME]]]
33 # Set the following to your ldap server(s)
34 ldap_default_servers = ldap::389
35 BASEDN = [[[SET THIS TO YOUR BASE DN IN LDAP]]]
37 acl_smtp_rcpt = acl_check_rcpt
38 acl_smtp_data = acl_check_data
46 rfc1413_query_timeout = 0s
47 ignore_bounce_errors_after = 2d
48 timeout_frozen_after = 7d
49 bounce_return_body = false
50 accept_8bitmime = true
54 smtp_load_reserve = 20
55 delay_warning = 4h:8h:24h
56 dns_again_means_nonexist = !+local_domains : !+relay_to_domains
58 spamd_address = 127.0.0.1 783
59 av_scanner = clamd:127.0.0.1 3310
63 split_spool_directory = true
64 check_spool_space = 100M
65 check_spool_inodes = 1000
67 # Logging - enable a bunch of extra useful stuff. Never know, could help
68 # one day, and at least its better than qmail! Har har!
70 log_selector = +delivery_size +received_sender +received_recipients \
71 +subject +sender_on_delivery
73 # NOTE TO SELF: Lets use syslog and have all six mail servers log to a
74 # central location so its easier to do statistics gathering and fault
79 # Secret for all machines in the cluster. Change it to whatever you feel
82 SECRET = Ni2opNyw2pNM3cmWn21nOSbwdq
84 GET_ADDRESS_DATA = ${lookup ldap {\
85 ldap:///BASEDN??sub?(&(uid=${quote_ldap:$local_part}@${quote_ldap:$domain}))\
89 GET_CATCHALL_DATA = ${lookup ldap {\
90 ldap:///BASEDN??sub?(&(uid=catchall@${quote_ldap:$domain}))\
94 MSGCOOKIE = ${hmac{md5}{SECRET}{$body_linecount}}
96 ######################################################################
97 # ROUTERS CONFIGURATION #
98 # Specifies how addresses are handled #
99 ######################################################################
105 domains = ! +local_domains
106 transport = remote_smtp
107 ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
112 condition = ${if eq {{$primary_hostname}{$domain} {1}{0}} }
115 data = ${lookup{$local_part}lsearch{/etc/aliases}}
116 file_transport = address_file
117 pipe_transport = address_pipe
119 # the forward router does the initial LDAP lookup. It then caches this in
120 # $address_data for use by any of the other routers. Each router will fall
121 # through if they then don't meet their condition.
125 address_data = GET_ADDRESS_DATA
126 # data is intentionally left blank so that the router will decline
127 # we just want this router to do a lookup so the results are availble
128 # for the other routers.
131 # OK, this is where we start supporting crazy qmail-ldap stuff. First, we
132 # check if the address has a deliveryMode of 'forwardonly'. forwardonly is
133 # a misnomer, because its possible for and address to be a forward, a mailbox
134 # and an autoreply. So, we make it do the forward, and check to see if it is
135 # also a reply or localdelivery, if so we set unseen to yes to make Exim
136 # copy the message and send it to the next router.
140 condition = ${if match {${extract{deliveryMode}{$address_data}}}{forwardonly} {1}{0}}
141 data = ${extract{mailForwardingAddress}{$address_data}}
142 unseen = ${if or {{match {${extract{deliveryMode}{$address_data}}}{reply}} \
143 {match {${extract{deliveryMode}{$address_data}}}{localdelivery}}} \
146 # Same deal, check if its a reply, if so we send it to the correct transport.
147 # After, we see if it needs to go to localdelivery as well.
151 condition = ${if match {${extract{deliveryMode}{$address_data}}}{reply} {1}{0}}
152 transport = auto_reply
153 unseen = ${if match {${extract{deliveryMode}{$address_data}}}{localdelivery} {yes}{no}}
157 condition = ${if match {${extract{deliveryMode}{$address_data}}}{localdelivery} {1}{0}}
158 transport = local_delivery
160 # If we've reached this point, the account doesn't exist, so we need to
161 # check to see if there is a catchall account, and if so do the usual for
162 # it too. NOTE: we do not support auto-reply in a catch-all.
164 # This could, of course, be abused by someone assigning an auto-reply to
165 # a forward_catchall.
167 # NOTE TO SELF: See if reply router can be failed if an address comes from
172 address_data = GET_CATCHALL_DATA
173 # data is intentionally left blank so that the router will decline
174 # just want this router to do a lookup.
176 # could probably do a no_more = true based on the result of that LDAP
177 # lookup to skip the next few routers, but there is no point as they are
178 # not doing anything heavy so I'll just let them fall through and fail.
180 # The catchall routers are exactly the same as the above routers, except
181 # they make use of the GET_CATCHALL_DATA address_data to decide what to do
186 condition = ${if match {${extract{deliveryMode}{$address_data}}}{forwardonly} {1}{0}}
187 data = ${extract{mailForwardingAddress}{$address_data}}
188 unseen = ${if match {${extract{deliveryMode}{$address_data}}}{localdelivery} {yes}{no}}
190 localdelivery_catchall:
192 condition = ${if match {${extract{deliveryMode}{$address_data}}}{localdelivery} {1}{0}}
193 transport = local_delivery
195 ######################################################################
196 # TRANSPORTS CONFIGURATION #
197 ######################################################################
204 # Deliver to the mailbox specified in the LDAP directory. We make sure
205 # that quota is obeyed, and we try to send a messge to the user if it
211 directory = ${extract{mailMessageStore}{$address_data}}/Maildir
213 directory_mode = 0700
220 quota = ${eval:${sg{${extract{1}{,}{${extract{mailQuota}{$address_data}}}}}{S}{}}/1024}K
221 maildir_use_size_file = true
222 quota_warn_threshold = 85%
224 # We set this to iso-2022-jp because we're in japan. Set it to whatever.
228 subject = "[Auto-Reply] $header_subject"
229 headers = "Content-Type: text/plain; charset=iso-2022-jp"
230 to = "$sender_address"
231 text = ${extract{mailReplyText}{$address_data}}
232 from = $local_part@$domain
235 ######################################################################
236 # ACL CONFIGURATION #
237 # Specifies access control lists for incoming SMTP mail #
238 ######################################################################
242 # You should probably set up exiscan-acl's mime check here to scan for viruses
243 # and spam and reject at SMTP time. As I won't be doing that for a while, I've
244 # left it as an exercise for the reader.
248 deny message = Restricted characters in address
249 domains = +local_domains
250 local_parts = ^[.] : ^.*[@%!/|]
251 deny message = Restricted characters in address
252 domains = !+local_domains
253 local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
254 accept local_parts = postmaster
255 domains = +local_domains
256 require verify = sender
257 accept domains = +local_domains
260 accept domains = +relay_to_domains
263 accept hosts = +relay_from_hosts
264 accept authenticated = *
265 deny message = relay not permitted
268 require verify = header_syntax
269 message = This message has malformed headers.
270 deny message = This message contains malformed MIME ($demime_reason).
272 condition = ${if >{$demime_errorlevel}{2}{1}{0}}
273 deny message = We do not accept ".$found_extension" attachments here as \
274 they are common file extensions for viruses. If you wish \
275 to send such an attachment, please zip it first.
276 demime = bat:btm:cmd:com:cpl:dll:exe:lnk:msi:pif:prf:reg:scr:vbs:url
281 # Address or Domain Error Retries
282 # ----------------- ----- -------
284 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
286 ######################################################################
287 # REWRITE CONFIGURATION #
288 ######################################################################
290 # There are no rewriting specifications in this default configuration file.
294 ######################################################################
295 # AUTHENTICATION CONFIGURATION #
296 ######################################################################
298 # There are no authenticator specifications in this default configuration file.
305 server_condition = ${if ldapauth {user="uid=${quote_ldap_dn:$2},BASEDN" \
306 pass=${quote:$3} ldap:///}{yes}{no}}
313 server_prompts = Username:: : Password::
314 server_condition = ${if ldapauth {user="uid=${quote_ldap_dn:$1},BASEDN" \
315 pass=${quote:$2} ldap:///}{yes}{no}}
318 ######################################################################
319 # CONFIGURATION FOR local_scan() #
320 ######################################################################
324 # End of Exim configuration file