maddy

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

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

  1# SMTP/LMTP/Submission endpoint
  2
  3Module 'smtp' is a listener that implements ESMTP protocol with optional
  4authentication, LMTP and Submission support. Incoming messages are processed in
  5accordance with pipeline rules (explained in Message pipeline section below).
  6
  7```
  8smtp tcp://0.0.0.0:25 {
  9    hostname example.org
 10    tls /etc/ssl/private/cert.pem /etc/ssl/private/pkey.key
 11    io_debug no
 12    debug no
 13    insecure_auth no
 14    sasl_login no
 15    read_timeout 10m
 16    write_timeout 1m
 17    max_message_size 32M
 18    max_header_size 1M
 19    auth pam
 20    defer_sender_reject yes
 21    dmarc yes
 22    smtp_max_line_length 4000
 23    limits {
 24        endpoint rate 10
 25        endpoint concurrency 500
 26    }
 27
 28    # Example pipeline ocnfiguration.
 29    destination example.org {
 30        deliver_to &local_mailboxes
 31    }
 32    default_destination {
 33        reject
 34    }
 35}
 36```
 37
 38## Configuration directives
 39
 40### hostname _string_
 41Default: global directive value
 42
 43Server name to use in SMTP banner.
 44
 45```
 46220 example.org ESMTP Service Ready
 47```
 48
 49---
 50
 51### tls _certificate-path_ _key-path_ { ... }
 52Default: global directive value
 53
 54TLS certificate & key to use. Fine-tuning of other TLS properties is possible
 55by specifying a configuration block and options inside it:
 56
 57```
 58tls cert.crt key.key {
 59    protocols tls1.2 tls1.3
 60}
 61```
 62
 63See [TLS configuration / Server](/reference/tls/#server-side) for details.
 64
 65---
 66
 67### proxy_protocol _trusted ips..._ { ... } <br>
 68Default: not enabled
 69
 70Enable use of HAProxy PROXY protocol. Supports both v1 and v2 protocols.
 71If a list of trusted IP addresses or subnets is provided, only connections
 72from those will be trusted.
 73
 74TLS for the channel between the proxies and maddy can be configured
 75using a 'tls' directive:
 76```
 77proxy_protocol {
 78    trust 127.0.0.1 ::1 192.168.0.1/24
 79    tls &proxy_tls
 80}
 81```
 82
 83---
 84
 85### io_debug _boolean_
 86Default: `no`
 87
 88Write all commands and responses to stderr.
 89
 90---
 91
 92### debug _boolean_
 93Default: global directive value
 94
 95Enable verbose logging.
 96
 97---
 98
 99### insecure_auth _boolean_
100Default: `no` (`yes` if TLS is disabled)
101
102Allow plain-text authentication over unencrypted connections. Not recommended!
103
104---
105
106### sasl_login _boolean_
107Default: `no`
108
109Enable support for SASL LOGIN authentication mechanism used by
110some outdated clients.
111
112---
113
114### read_timeout _duration_
115Default: `10m`
116
117I/O read timeout.
118
119---
120
121### write_timeout _duration_
122Default: `1m`
123
124I/O write timeout.
125
126---
127
128### max_message_size _size_
129Default: `32M`
130
131Limit the size of incoming messages to 'size'.
132
133---
134
135### max_header_size _size_
136Default: `1M`
137
138Limit the size of incoming message headers to 'size'.
139
140---
141
142### auth _module-reference_
143Default: not specified
144
145Use the specified module for authentication.
146
147---
148
149### defer_sender_reject _boolean_
150Default: `yes`
151
152Apply sender-based checks and routing logic when first RCPT TO command
153is received. This allows maddy to log recipient address of the rejected
154message and also improves interoperability with (improperly implemented)
155clients that don't expect an error early in session.
156
157---
158
159### max_logged_rcpt_errors _integer_
160Default: `5`
161
162Amount of RCPT-time errors that should be logged. Further errors will be
163handled silently. This is to prevent log flooding during email dictionary
164attacks (address probing).
165
166---
167
168### max_received _integer_
169Default: `50`
170
171Max. amount of Received header fields in the message header. If the incoming
172message has more fields than this number, it will be rejected with the permanent error
1735.4.6 ("Routing loop detected").
174
175---
176
177### buffer `ram`<br>buffer `fs` _path_ <br>buffer `auto` _max-size_ _path_
178Default: `auto 1M StateDirectory/buffer`
179
180Temporary storage to use for the body of accepted messages.
181
182- `ram` – Store the body in RAM.
183- `fs` – Write out the message to the FS and read it back as needed.
184_path_ can be omitted and defaults to StateDirectory/buffer.
185- `auto` – Store message bodies smaller than `_max_size_` entirely in RAM,
186otherwise write them out to the FS. _path_ can be omitted and defaults to `StateDirectory/buffer`.
187
188---
189
190### smtp_max_line_length _integer_
191Default: `4000`
192
193The maximum line length allowed in the SMTP input stream. If client sends a
194longer line - connection will be closed and message (if any) will be rejected
195with a permanent error.
196
197RFC 5321 has the recommended limit of 998 bytes. Servers are not required
198to handle longer lines correctly but some senders may produce them.
199
200Unless BDAT extension is used by the sender, this limitation also applies to
201the message body.
202
203---
204
205### dmarc _boolean_
206Default: `yes`
207
208Enforce sender's DMARC policy. Due to implementation limitations, it is not a
209check module.
210
211**Note**: Report generation is not implemented now.
212
213**Note**: DMARC needs SPF and DKIM checks to function correctly.
214Without these, DMARC check will not run.
215
216---
217
218## Rate & concurrency limiting
219
220### limits { ... }
221Default: no limits
222
223This allows configuring a set of message flow restrictions including
224max. concurrency and rate per-endpoint, per-source, per-destination.
225
226Limits are specified as directives inside the block:
227
228```
229limits {
230	all rate 20
231	destination concurrency 5
232}
233```
234
235Supported limits:
236
237### _scope_ rate _burst_ _period_
238
239Rate limit. Restrict the amount of messages processed in _period_ to
240_burst_ messages. If period is not specified, 1 second is used.
241
242### _scope_ concurrency _max_
243Concurrency limit. Restrict the amount of messages processed in parallel
244to _max_.
245
246For each supported limitation, _scope_ determines whether it should be applied
247for all messages ("all"), per-sender IP ("ip"), per-sender domain ("source") or
248per-recipient domain ("destination"). Having a scope other than "all" means
249that the restriction will be enforced independently for each group determined
250by scope. E.g.  "ip rate 20" means that the same IP cannot send more than 20
251messages per second. "destination concurrency 5" means that no more than 5
252messages can be sent in parallel to a single domain.
253
254**Note**: At the moment, SMTP endpoint on its own does not support per-recipient
255limits.  They will be no-op. If you want to enforce a per-recipient restriction
256on outbound messages, do so using 'limits' directive for the 'table.remote' module
257
258It is possible to share limit counters between multiple endpoints (or any other
259modules). To do so define a top-level configuration block for module "limits"
260and reference it where needed using standard & syntax. E.g.
261
262```
263limits inbound_limits {
264	all rate 20
265}
266
267smtp smtp://0.0.0.0:25 {
268	limits &inbound_limits
269	...
270}
271
272submission tls://0.0.0.0:465 {
273	limits &inbound_limits
274	...
275}
276```
277
278Using an "all rate" restriction in such way means that no more than 20
279messages can enter the server through both endpoints in one second.
280
281# Submission module (submission)
282
283Module 'submission' implements all functionality of the 'smtp' module and adds
284certain message preprocessing on top of it, additionally authentication is
285always required.
286
287'submission' module checks whether addresses in header fields From, Sender, To,
288Cc, Bcc, Reply-To are correct and adds Message-ID and Date if it is missing.
289
290```
291submission tcp://0.0.0.0:587 tls://0.0.0.0:465 {
292    # ... same as smtp ...
293}
294```
295
296# LMTP module (lmtp)
297
298Module 'lmtp' implements all functionality of the 'smtp' module but uses
299LMTP (RFC 2033) protocol.
300
301```
302lmtp unix://lmtp.sock {
303    # ... same as smtp ...
304}
305```
306
307## Limitations of LMTP implementation
308
309- Can't be used with TCP.
310- Delivery to 'sql' module storage is always atomic, either all recipients will
311  succeed or none of them will.
312