From becc825c8bf143b7fcdaee5e7f39f36bd8677706 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 27 Sep 2026 16:00:48 +0200 Subject: [PATCH] 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) --- cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 | 1 + cmdeploy/src/cmdeploy/tests/online/test_1_basic.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 b/cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 index 04ab3643..dd627f61 100644 --- a/cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 +++ b/cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 @@ -75,6 +75,7 @@ http { server_name {{ config.mail_domain }} mta-sts.{{ config.mail_domain }}; location /mxdeliv { + client_max_body_size {{ config.max_message_size }}; proxy_pass http://127.0.0.1:{{ config.filtermail_http_port_incoming }}; } diff --git a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py index 9a32ef7a..93c64794 100644 --- a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py +++ b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py @@ -5,6 +5,7 @@ import subprocess import time import pytest +import requests from chatmaild.config import is_valid_ipv4 from cmdeploy import remote @@ -326,3 +327,14 @@ def test_nginx_access_log_only_defined_once(sshdomain): assert len(access_logs) == 1, ( f"expected 1 access_log, found {len(access_logs)}: {access_logs}" ) + + +@pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning") +def test_mxdeliv_respects_max_message_size(maildomain, chatmail_config): + url = f"https://{maildomain}/mxdeliv" + verify = chatmail_config.tls_cert_mode == "acme" + size = chatmail_config.max_message_size + res = requests.post(url, data=b"x" * size, verify=verify) + assert res.text == "500 Invalid DATA" + res = requests.post(url, data=b"x" * (size + 1), verify=verify) + assert res.status_code == 413