Skip to content

Commit becc825

Browse files
committed
fix: allow http MX delivery to carry max-message-sized messages
it otherwise uses the 1MB nginx default body size, forcing a fallback to SMTP (which if not available, fails the delivery)
1 parent b938882 commit becc825

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎cmdeploy/src/cmdeploy/nginx/nginx.conf.j2‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ http {
7575
server_name {{ config.mail_domain }} mta-sts.{{ config.mail_domain }};
7676

7777
location /mxdeliv {
78+
client_max_body_size {{ config.max_message_size }};
7879
proxy_pass http://127.0.0.1:{{ config.filtermail_http_port_incoming }};
7980
}
8081

‎cmdeploy/src/cmdeploy/tests/online/test_1_basic.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import time
66

77
import pytest
8+
import requests
89
from chatmaild.config import is_valid_ipv4
910

1011
from cmdeploy import remote
@@ -326,3 +327,14 @@ def test_nginx_access_log_only_defined_once(sshdomain):
326327
assert len(access_logs) == 1, (
327328
f"expected 1 access_log, found {len(access_logs)}: {access_logs}"
328329
)
330+
331+
332+
@pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning")
333+
def test_mxdeliv_respects_max_message_size(maildomain, chatmail_config):
334+
url = f"https://{maildomain}/mxdeliv"
335+
verify = chatmail_config.tls_cert_mode == "acme"
336+
size = chatmail_config.max_message_size
337+
res = requests.post(url, data=b"x" * size, verify=verify)
338+
assert res.text == "500 Invalid DATA"
339+
res = requests.post(url, data=b"x" * (size + 1), verify=verify)
340+
assert res.status_code == 413

0 commit comments

Comments
 (0)