chiark / gitweb /
defs.m4: New macros for inserting separators into lists.
[exim-config] / local.m4
1 ### -*-m4-*-
2 ###
3 ### Local senders and recipients for distorted.org.uk Exim configuration
4 ###
5 ### (c) 2012 Mark Wooding
6 ###
7
8 ###----- Licensing notice ---------------------------------------------------
9 ###
10 ### This program is free software; you can redistribute it and/or modify
11 ### it under the terms of the GNU General Public License as published by
12 ### the Free Software Foundation; either version 2 of the License, or
13 ### (at your option) any later version.
14 ###
15 ### This program is distributed in the hope that it will be useful,
16 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ### GNU General Public License for more details.
19 ###
20 ### You should have received a copy of the GNU General Public License
21 ### along with this program; if not, write to the Free Software Foundation,
22 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 m4_define(<:FILTER_LOCALUSER:>,
25         <:FILTER_BASE
26         check_local_user
27         ignore_enotdir
28         sieve_useraddress = $local_part
29         sieve_subaddress = CONF_user_extaddr_fixup
30         sieve_vacation_directory = CONF_userconf_dir/vacation
31         condition = ${if exists {<:$1:>}}
32         file = <:$1:>:>)
33
34 ###--------------------------------------------------------------------------
35 ### Be flexible about originator addresses, as long as they probably work.
36
37 SECTION(global, priv)m4_dnl
38 local_from_suffix = CONF_user_suffix_list
39
40 SECTION(global, process)m4_dnl
41 ## Restrict users to plausible envelope sender addresses.  This is
42 ## surprisingly fiddly.  What I actually want to say is that the local part
43 ## must match ^$sender_ident(\$|-) and the domain part must match an
44 ## appropriate domain; but writing a conjunction is rather tricky.  And so we
45 ## must burn some addresslist variables.
46 addresslist wrong_local = ! +user_extaddr
47 addresslist wrong_domain = ! *@+public
48 addresslist wrong_address = +wrong_local : +wrong_domain
49 untrusted_set_sender = : \
50         ${if exists {CONF_sysconf_dir/auth-sender.conf} \
51              {${lookup {$sender_ident} \
52                        lsearch {CONF_sysconf_dir/auth-sender.conf} \
53                        {$value}}}} : \
54         ${LOOKUP_DOMAIN($sender_address_domain,
55                 {${if and {{match_local_part {$sender_ident} {+dom_users}} \
56                            {match_local_part {$sender_address_local_part} \
57                                              {+dom_locals}}} \
58                       {*}}})} : \
59         ! +wrong_address
60
61 ###--------------------------------------------------------------------------
62 ### Forwarding and redirection for incoming mail.
63
64 SECTION(routers, alias)m4_dnl
65 ## Look up the local part in the address map.
66 alias:
67         driver = redirect
68         allow_fail = true
69         allow_defer = true
70         user = CONF_filter_user
71         FILTER_TRANSPORTS
72         local_parts = nwildlsearch; CONF_alias_file
73         data = ${expand:$local_part_data}
74
75 SECTION(routers, real)m4_dnl
76 ## A special hack to get mail to a user who has a forward file.  Only for
77 ## special effects.
78 real:
79         driver = accept
80         check_local_user
81         local_part_prefix = real-
82         transport = deliver
83         condition = ${if match_ip {$sender_host_address} \
84                                   {<; ; 127.0.0.1 ; ::1}}
85
86 SECTION(routers, forward)m4_dnl
87 ## Handle user forward files.  Each user is granted an arbitrary number of
88 ## additional mailboxes named USER-SUFFIX.  Such addresses are handled by a
89 ## filter file `~/.mail/forward.suffix' in the USER's home directory.  The
90 ## filter may reject the incoming message (which is reported as an SMTP
91 ## rejection if possible).  Mail sent directly to the user is handled through
92 ## `~/.mail/forward', or `~/.forward', or if neither of those exists, by
93 ## writing the message to `/var/mail/USER'.
94 FILTER_ROUTER(filter_suffix,
95         <:FILTER_LOCALUSER(CONF_userconf_dir/forward.suffix)
96         local_part_suffix = CONF_user_suffix_list:>)
97 FILTER_ROUTER(filter,
98         <:FILTER_LOCALUSER(CONF_userconf_dir/forward):>)
99 FILTER_ROUTER(dot_forward,
100         <:FILTER_LOCALUSER($home/.forward):>)
101
102 SECTION(routers, deliver)m4_dnl
103 ## Deliver mail to a user, in the absence of any other instructions.
104 deliver:
105         driver = accept
106         check_local_user
107         transport = deliver
108         cannot_route_message = Unknown local part
109
110 DIVERT(null)
111 ###----- That's all, folks --------------------------------------------------