exim: Completely review the exim configuration.
[matthijs/servers/drsnuggles.git] / etc / exim4 / conf.d / router / 40_local_delivery
diff --git a/etc/exim4/conf.d/router/40_local_delivery b/etc/exim4/conf.d/router/40_local_delivery
new file mode 100644 (file)
index 0000000..ad6c559
--- /dev/null
@@ -0,0 +1,109 @@
+#################################
+# The routers that handle the actual local delivery of mail. These routers all
+# work just on the localhost "domain", so any previous routers that want to
+# have mail delivered locally should redirect to username@localhost and set
+# redirect_router to "local_delivery". These routers are not used directly on
+# incoming messages, the first router guarantees this.
+# 
+# These routers support .forward files, procmail and mbox delivery in
+# /var/mail, each tried in turn.
+#################################
+
+
+# Dummy noop router, that ensures that these routers are never called directly
+# on an incoming message and enforces that they only be called when a previous
+# router explicitely sets redirect_router to local_delivery.
+always_fail:
+  debug_print = "R: local_delivery for $local_part@$domain"
+  driver = redirect
+  data =
+  more = false
+  cannot_route_message = "Internal error"
+
+# Dummy noop router, that can be used by other routers for the value of
+# redirect_router or pass_router, without being dependent on the (order of)
+# actual delivery routers below.
+local_delivery:
+  debug_print = "R: local_delivery for $local_part@$domain"
+  driver = redirect
+  data =
+
+# This router handles forwarding using traditional .forward files in users'
+# home directories. It also allows mail filtering with a forward file
+# starting with the string "# Exim filter" or "# Sieve filter".
+#
+# The no_verify setting means that this router is skipped when Exim is
+# verifying addresses. Similarly, no_expn means that this router is skipped if
+# Exim is processing an EXPN command.
+#
+# The check_ancestor option means that if the forward file generates an
+# address that is an ancestor of the current one, the current one gets
+# passed on instead. This covers the case where A is aliased to B and B
+# has a .forward file pointing to A.
+#
+# The four transports specified at the end are those that are used when
+# forwarding generates a direct delivery to a directory, or a file, or to a
+# pipe, or sets up an auto-reply, respectively.
+#
+# Any syntax errors in the .forward are sent with the real- prefix, which the
+# real_local router directly delivers through the maildir_home transport,
+# avoiding the routers in this file.
+userforward:
+  debug_print = "R: userforward for $local_part@$domain"
+  driver = redirect
+  domains = localhost
+  check_local_user
+  file = $home/.forward
+  require_files = $local_part:$home/.forward
+  no_verify
+  no_expn
+  check_ancestor
+  allow_filter
+  forbid_smtp_code = true
+  directory_transport = address_directory
+  file_transport = address_file
+  pipe_transport = address_pipe
+  reply_transport = address_reply
+  skip_syntax_errors
+  syntax_errors_to = real-$local_part@$domain
+  syntax_errors_text = \
+    This is an automatically generated message. An error has\n\
+    been found in your .forward file. Details of the error are\n\
+    reported below. While this error persists, you will receive\n\
+    a copy of this message for every message that is addressed\n\
+    to you. If your .forward file is a filter file, or if it is\n\
+    a non-filter file containing no valid forwarding addresses,\n\
+    a copy of each incoming message will be put in your normal\n\
+    mailbox. If a non-filter file contains at least one valid\n\
+    forwarding address, forwarding to the valid addresses will\n\
+    happen, and those will be the only deliveries that occur.
+
+# Let procmail deliver the message if a global or local (in the user's
+# homedir) procmailrc exists.
+procmail:
+  debug_print = "R: procmail for $local_part@$domain"
+  driver = accept
+  domains = localhost
+  check_local_user
+  transport = procmail_pipe
+  # emulate OR with "if exists"-expansion
+  require_files = ${local_part}:\
+                  ${if exists{/etc/procmailrc}\
+                    {/etc/procmailrc}{${home}/.procmailrc}}:\
+                  +/usr/bin/procmail
+  no_verify
+  no_expn
+
+# This router delivers to /var/mail.
+local_user:
+  debug_print = "R: local_user for $local_part@$domain"
+  driver = accept
+  domains = localhost
+  check_local_user
+  local_parts = ! root
+  transport = maildir_home
+  # If we get here, some previous router redirected to a non-existing user.
+  # That should not happen!
+  cannot_route_message = Unknown user: This should not happen
+
+# vim: set sts=2 expandtab sw=2 ai: