maddy

Fork https://github.com/foxcpp/maddy

git clone git://git.lin.moe/go/maddy.git

  1# Remote MX delivery
  2
  3Module that implements message delivery to remote MTAs discovered via DNS MX
  4records. You probably want to use it with queue module for reliability.
  5
  6If a message check marks a message as 'quarantined', remote module
  7will refuse to deliver it.
  8
  9## Configuration directives
 10
 11```
 12target.remote {
 13    hostname mx.example.org
 14    debug no
 15}
 16```
 17
 18### hostname _domain_
 19Default: global directive value
 20
 21Hostname to use client greeting (EHLO/HELO command). Some servers require it to
 22be FQDN, SPF-capable servers check whether it corresponds to the server IP
 23address, so it is better to set it to a domain that resolves to the server IP.
 24
 25---
 26
 27### limits { ... }
 28Default: no limits
 29
 30See ['limits' directive for SMTP endpoint](/reference/endpoints/smtp/#rate-concurrency-limiting).
 31It works the same except for address domains used for
 32per-source/per-destination are as observed when message exits the server.
 33
 34---
 35
 36### local_ip _ip-address_
 37Default: empty
 38
 39Choose the local IP to bind for outbound SMTP connections.
 40
 41---
 42
 43### force_ipv4 _boolean_
 44Default: `false`
 45
 46Force resolving outbound SMTP domains to IPv4 addresses. Some server providers
 47do not offer a way to properly set reverse PTR domains for IPv6 addresses; this
 48option makes maddy only connect to IPv4 addresses so that its public IPv4 address
 49is used to connect to that server, and thus reverse PTR checks are made against
 50its IPv4 address.
 51
 52Warning: this may break sending outgoing mail to IPv6-only SMTP servers.
 53
 54---
 55
 56### connect_timeout _duration_
 57Default: `5m`
 58
 59Timeout for TCP connection establishment.
 60
 61RFC 5321 recommends 5 minutes for "initial greeting" that includes TCP
 62handshake. maddy uses two separate timers - one for "dialing" (DNS A/AAAA
 63lookup + TCP handshake) and another for "initial greeting". This directive
 64configures the former. The latter is not configurable and is hardcoded to be
 655 minutes.
 66
 67---
 68
 69### command_timeout _duration_
 70Default: `5m`
 71
 72Timeout for any SMTP command (EHLO, MAIL, RCPT, DATA, etc).
 73
 74If STARTTLS is used this timeout also applies to TLS handshake.
 75
 76RFC 5321 recommends 5 minutes for MAIL/RCPT and 3 minutes for
 77DATA.
 78
 79---
 80
 81### submission_timeout _duration_
 82Default: `12m`
 83
 84Time to wait after the entire message is sent (after "final dot").
 85
 86RFC 5321 recommends 10 minutes.
 87
 88---
 89
 90### debug _boolean_
 91Default: global directive value
 92
 93Enable verbose logging.
 94
 95---
 96
 97### requiretls_override _boolean_
 98Default: `true`
 99
100Allow local security policy to be disabled using 'TLS-Required' header field in
101sent messages. Note that the field has no effect if transparent forwarding is
102used, message body should be processed before outbound delivery starts for it
103to take effect (e.g. message should be queued using 'queue' module).
104
105---
106
107### relaxed_requiretls _boolean_
108Default: `true`
109
110This option disables strict conformance with REQUIRETLS specification and
111allows forwarding of messages 'tagged' with REQUIRETLS to MXes that are not
112advertising REQUIRETLS support. It is meant to allow REQUIRETLS use without the
113need to have support from all servers. It is based on the assumption that
114server referenced by MX record is likely the final destination and therefore
115there is only need to secure communication towards it and not beyond.
116
117---
118
119### conn_reuse_limit _integer_
120Default: `10`
121
122Amount of times the same SMTP connection can be used.
123Connections are never reused if the previous DATA command failed.
124
125---
126
127### conn_max_idle_count _integer_
128Default: `10`
129
130Max. amount of idle connections per recipient domains to keep in cache.
131
132---
133
134### conn_max_idle_time _integer_
135Default: `150` (2.5 min)
136
137Amount of time the idle connection is still considered potentially usable.
138
139---
140
141## Security policies
142
143### mx_auth { ... }
144Default: no policies
145
146'remote' module implements a number of of schemes and protocols necessary to
147ensure security of message delivery. Most of these schemes are concerned with
148authentication of recipient server and TLS enforcement.
149
150To enable mechanism, specify its name in the `mx_auth` directive block:
151
152```
153mx_auth {
154	dane
155	mtasts
156}
157```
158
159Additional configuration is possible if supported by the mechanism by
160specifying additional options as a block for the corresponding mechanism.
161E.g.
162
163```
164mtasts {
165	cache ram
166}
167```
168
169If the `mx_auth` directive is not specified, no mechanisms are enabled. Note
170that, however, this makes outbound SMTP vulnerable to a numerous downgrade
171attacks and hence not recommended.
172
173It is possible to share the same set of policies for multiple 'remote' module
174instances by defining it at the top-level using `mx_auth` module and then
175referencing it using standard & syntax:
176
177```
178mx_auth outbound_policy {
179	dane
180	mtasts {
181		cache ram
182	}
183}
184
185# ... somewhere else ...
186
187deliver_to remote {
188	mx_auth &outbound_policy
189}
190
191# ... somewhere else ...
192
193deliver_to remote {
194	mx_auth &outbound_policy
195	tls_client { ... }
196}
197```
198
199---
200
201### MTA-STS
202
203Checks MTA-STS policy of the recipient domain. Provides proper authentication
204and TLS enforcement for delivery, but partially vulnerable to persistent active
205attacks.
206
207Sets MX level to "mtasts" if the used MX matches MTA-STS policy even if it is
208not set to "enforce" mode.
209
210```
211mtasts {
212	cache fs
213	fs_dir StateDirectory/mtasts_cache
214}
215```
216
217### cache `fs` | `ram`
218Default: `fs`
219
220Storage to use for MTA-STS cache. 'fs' is to use a filesystem directory, 'ram'
221to store the cache in memory.
222
223It is recommended to use 'fs' since that will not discard the cache (and thus
224cause MTA-STS security to disappear) on server restart. However, using the RAM
225cache can make sense for high-load configurations with good uptime.
226
227### fs_dir _directory_
228Default: `StateDirectory/mtasts_cache`
229
230Filesystem directory to use for policies caching if 'cache' is set to 'fs'.
231
232---
233
234### DNSSEC
235
236Checks whether MX records are signed. Sets MX level to "dnssec" is they are.
237
238maddy does not validate DNSSEC signatures on its own. Instead it relies on
239the upstream resolver to do so by causing lookup to fail when verification
240fails and setting the AD flag for signed and verified zones. As a safety
241measure, if the resolver is not 127.0.0.1 or ::1, the AD flag is ignored.
242
243DNSSEC is currently not supported on Windows and other platforms that do not
244have the /etc/resolv.conf file in the standard format.
245
246```
247dnssec { }
248```
249
250---
251
252### DANE
253
254Checks TLSA records for the recipient MX. Provides downgrade-resistant TLS
255enforcement.
256
257Sets TLS level to "authenticated" if a valid and matching TLSA record uses
258DANE-EE or DANE-TA usage type.
259
260See above for notes on DNSSEC. DNSSEC support is required for DANE to work.
261
262```
263dane { }
264```
265
266---
267
268### Local policy
269
270Checks effective TLS and MX levels (as set by other policies) against local
271configuration.
272
273```
274local_policy {
275	min_tls_level none
276	min_mx_level none
277}
278```
279
280Using `local_policy off` is equivalent to setting both directives to `none`.
281
282### min_tls_level `none` | `encrypted` | `authenticated`
283Default: `encrypted`
284
285Set the minimal TLS security level required for all outbound messages.
286
287See [Security levels](/seclevels) page for details.
288
289### min_mx_level `none` | `mtasts` | `dnssec`
290Default: `none`
291
292Set the minimal MX security level required for all outbound messages.
293
294See [Security levels](/seclevels) page for details.
295