-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexim-main.j2
294 lines (222 loc) · 8.94 KB
/
exim-main.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
######################################################################
# MAIN CONFIGURATION SETTINGS #
######################################################################
primary_hostname = {{ inventory_hostname }}
domainlist main_domains = {{ domain }} : *.{{ domain }} : *.local.{{ domain }}
domainlist fw_domains = {{ alt_domain }} : *.{{ alt_domain }} {% for d in fw_domains %}: {{ d }} {% endfor %}
domainlist list_domains = lists.{{ domain }}
domainlist local_domains = @ : +main_domains : +fw_domains : +list_domains
domainlist dead_domains = <{% for d in dead_domains %}; {{ d }} {% endfor %}
domainlist relay_to_domains =
hostlist relay_from_hosts = <; localhost {% for ip in ips %}; {{ ip }} {% endfor %}
acl_smtp_rcpt = acl_check_rcpt
acl_smtp_data = acl_check_data
spamd_address = 127.0.0.1 783
tls_advertise_hosts = *
tls_certificate = /etc/letsencrypt/live/{{ inventory_hostname }}/fullchain.pem
tls_privatekey = /etc/letsencrypt/live/{{ inventory_hostname }}/privkey.pem
daemon_smtp_ports = 25 : 465 : 587
tls_on_connect_ports = 465
qualify_domain = {{ inventory_hostname }}
never_users = root
host_lookup = *
prdr_enable = true
log_file_path =:syslog
log_selector = +smtp_protocol_error +smtp_syntax_error +tls_certificate_verified
ignore_bounce_errors_after = 2d
timeout_frozen_after = 7d
######################################################################
# ACL CONFIGURATION #
# Specifies access control lists for incoming SMTP mail #
######################################################################
begin acl
spf_test:
warn set acl_m_spf_record = {{ '${lookup dnsdb{txt=$sender_address_domain}{$value}}' }}
# From local machines
accept hosts = +relay_from_hosts
add_header = Received-SPF: pass ({{ domain }}: {{ 'message originates from trusted relay) client-ip=${sender_host_address};' }}
# From authed users
accept authenticated = *
condition = ${if eq{$authenticated_id}{${listextract{1}{<@ $sender_address}}}}
add_header = Received-SPF: pass (shh.sh: message originates from authenticated user)
# No SPF record
accept !condition = {{ '${if def:acl_m_spf_record}' }}
add_header = Received-SPF: none ({{ domain }}: {{ '${sender_address} does not designate permitted sender hosts) client-ip=${sender_host_address};' }}
# SPF +all is meaningless
accept condition = {{ '${if match {$acl_m_spf_record}{\\\\+all}}' }}
add_header = Received-SPF: none ({{ domain }}: {{ '${sender_address} does not designate permitted sender hosts) client-ip=${sender_host_address};' }}
accept spf = pass
set acl_m_spf_pass = $acl_m_spf_record
add_header = Received-SPF: pass ({{ domain }}: {{ 'domain of ${sender_address} designates ${sender_host_address} as permitted sender) client-ip=${sender_host_address};' }}
accept spf = fail
set acl_m_spf_fail = $acl_m_spf_record
add_header = Received-SPF: softfail ({{ domain }}: {{ 'domain of ${sender_address} does not designate ${sender_host_address} as permitted sender) client-ip=${sender_host_address};' }}
accept
acl_check_rcpt:
accept hosts = :
control = dkim_disable_verify
deny message = Restricted characters in address
domains = +local_domains
local_parts = ^[.] : ^.*[@%!/|]
deny message = Restricted characters in address
domains = !+local_domains
local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
deny message = Known spam destination
domains = +dead_domains
accept local_parts = postmaster
domains = +local_domains
require verify = sender
accept hosts = +relay_from_hosts
control = submission
control = dkim_disable_verify
accept authenticated = *
control = submission
control = dkim_disable_verify
require message = relay not permitted
domains = +local_domains : +relay_to_domains
require verify = recipient
accept
acl_check_data:
# From authed users
accept authenticated = *
condition = ${if eq{$authenticated_id}{${listextract{1}{<@ $sender_address}}}}
add_header = X-Spam-Score: 0.0 (-)\n\
X-Spam-Status: 0
warn spam = nobody:true
add_header = X-Spam-Score: $spam_score ($spam_bar)\n\
X-Spam-Report: $spam_report\n\
X-Spam-Status: {{ '${if >{$spam_score_int}{50} {1}{0}}' }}
accept acl = spf_test
condition = ${if def:acl_m_spf_pass}
accept
######################################################################
# ROUTERS CONFIGURATION #
# Specifies how addresses are handled #
######################################################################
# THE ORDER IN WHICH THE ROUTERS ARE DEFINED IS IMPORTANT! #
# An address is passed to each router in turn until it is accepted. #
######################################################################
begin routers
dnslookup:
driver = dnslookup
domains = ! +local_domains
transport = remote_smtp_rewrite
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 ; ::1
no_more
listserv_catch:
driver = redirect
domains = +list_domains
data = postmaster+listserv@shh.sh
rewrite_router:
domains = +local_domains
driver = redirect
allow_fail
allow_defer
data = $local_part@{{ domain }}
system_aliases:
driver = redirect
allow_fail
allow_defer
local_part_suffix = +* : -*
local_part_suffix_optional
data = {{ '${lookup{$local_part}lsearch{/etc/mail/aliases}}' }}
file_transport = address_file
pipe_transport = address_pipe
userforward:
driver = redirect
check_local_user
local_part_suffix = +* : -*
local_part_suffix_optional
file = $home/.forward
no_verify
no_expn
check_ancestor
file_transport = address_file
pipe_transport = address_pipe
reply_transport = address_reply
localuser:
driver = accept
check_local_user
local_part_suffix = +* : -*
local_part_suffix_optional
transport = procmail
catchall_scan:
driver = redirect
condition = {{ '${if >{$spam_score_int}{50}{1}{0}}' }}
data = spam@{{ domain }}
catchall:
driver = redirect
data = catchall@{{ domain }}
######################################################################
# TRANSPORTS CONFIGURATION #
######################################################################
# ORDER DOES NOT MATTER #
# Only one appropriate transport is called for each delivery. #
######################################################################
begin transports
remote_smtp:
driver = smtp
dkim_domain = {{ '${lc:${domain:$h_from:}}' }}
dkim_selector = 20160724
dkim_private_key = /etc/mail/dkim/dkim.{{ domain }}
dkim_canon = relaxed
headers_remove = Received
remote_smtp_rewrite:
driver = smtp
headers_rewrite = *@*.{{ alt_domain }} $1@{{ domain }} : *@*.{{ domain }} $1@{{ domain }}
return_path = {{ '${sender_address_local_part}' }}@{{ domain }}
dkim_domain = {{ '${lc:${domain:$h_from:}}' }}
dkim_selector = 20160724
dkim_private_key = /etc/mail/dkim/dkim.{{ domain }}
dkim_canon = relaxed
headers_remove = Received
local_delivery:
driver = appendfile
# file = /var/mail/$local_part
delivery_date_add
envelope_to_add
return_path_add
create_directory = true
directory = {{ '/home/${local_part}/.mail' }}
maildir_format
procmail:
driver = pipe
command = /usr/bin/procmail -d $local_part
return_path_add
delivery_date_add
envelope_to_add
check_string = "From "
escape_string = ">From "
umask = 077
user = $local_part
address_pipe:
driver = pipe
return_output
address_file:
driver = appendfile
delivery_date_add
envelope_to_add
return_path_add
address_reply:
driver = autoreply
######################################################################
# RETRY CONFIGURATION #
######################################################################
begin retry
# Address or Domain Error Retries
# ----------------- ----- -------
* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
######################################################################
# REWRITE CONFIGURATION #
######################################################################
begin rewrite
######################################################################
# AUTHENTICATION CONFIGURATION #
######################################################################
begin authenticators
PLAIN:
driver = dovecot
public_name = PLAIN
server_socket = /var/run/dovecot/exim-auth
server_set_id = $auth1
server_advertise_condition = ${if def:tls_in_cipher}