Skip to content

Commit 66cb717

Browse files
committed
endpoint/smtp: Allow to change the line length limit enforced by go-smtp
See #352.
1 parent 86eca55 commit 66cb717

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

docs/man/maddy-smtp.5.scd

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ smtp tcp://0.0.0.0:25 {
2121
auth pam
2222
defer_sender_reject yes
2323
dmarc yes
24-
limits {
25-
endpoint rate 10
26-
endpoint concurrency 500
27-
}
24+
smtp_max_line_length 4000
25+
limits {
26+
endpoint rate 10
27+
endpoint concurrency 500
28+
}
2829
2930
# Example pipeline ocnfiguration.
3031
destination example.org {
@@ -139,6 +140,19 @@ Store message bodies smaller than _max_size_ entirely in RAM, otherwise write
139140
them out to the FS.
140141
_path_ can be omitted and defaults to StateDirectory/buffer.
141142

143+
*Syntax*: smtp_max_line_length _integer_ ++
144+
*Default*: 4000
145+
146+
The maximum line length allowed in the SMTP input stream. If client sends a
147+
longer line - connection will be closed and message (if any) will be rejected
148+
with a permanent error.
149+
150+
RFC 5321 has the recommended limit of 998 bytes. Servers are not required
151+
to handle longer lines correctly but some senders may produce them.
152+
153+
Unless BDAT extension is used by the sender, this limitation also applies to
154+
the message body.
155+
142156
*Syntax*: dmarc _boolean_ ++
143157
*Default*: yes
144158

internal/endpoint/smtp/smtp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func (endp *Endpoint) setConfig(cfg *config.Map) error {
256256
}, bufferModeDirective, &endp.buffer)
257257
cfg.Custom("tls", true, endp.name != "lmtp", nil, tls2.TLSDirective, &endp.serv.TLSConfig)
258258
cfg.Bool("insecure_auth", endp.name == "lmtp", false, &endp.serv.AllowInsecureAuth)
259+
cfg.Int("smtp_max_line_length", false, false, 4000, &endp.serv.MaxLineLength)
259260
cfg.Bool("io_debug", false, false, &ioDebug)
260261
cfg.Bool("debug", true, false, &endp.Log.Debug)
261262
cfg.Bool("defer_sender_reject", false, true, &endp.deferServerReject)

0 commit comments

Comments
 (0)