diff --git a/chatmaild/src/chatmaild/config.py b/chatmaild/src/chatmaild/config.py index c71e0b27..0fcc494d 100644 --- a/chatmaild/src/chatmaild/config.py +++ b/chatmaild/src/chatmaild/config.py @@ -20,6 +20,7 @@ class Config: self.mail_domain = params["mail_domain"] self.max_user_send_per_minute = int(params["max_user_send_per_minute"]) self.max_mailbox_size = params["max_mailbox_size"] + self.max_message_size = int(params.get("max_message_size", "31457280")) self.delete_mails_after = params["delete_mails_after"] self.delete_inactive_users_after = int(params["delete_inactive_users_after"]) self.username_min_length = int(params["username_min_length"]) @@ -73,7 +74,7 @@ def write_initial_config(inipath, mail_domain, overrides): new_line = line.strip() if new_line and new_line[0] not in "#[": name, value = map(str.strip, new_line.split("=", maxsplit=1)) - value = overrides.pop(name, value) + value = extra.pop(name, value) new_line = f"{name} = {value}" new_lines.append(new_line) diff --git a/chatmaild/src/chatmaild/ini/chatmail.ini.f b/chatmaild/src/chatmaild/ini/chatmail.ini.f index 1b951356..ab65775e 100644 --- a/chatmaild/src/chatmaild/ini/chatmail.ini.f +++ b/chatmaild/src/chatmaild/ini/chatmail.ini.f @@ -17,6 +17,9 @@ max_user_send_per_minute = 60 # maximum mailbox size of a chatmail address max_mailbox_size = 100M +# maximum message size for an e-mail in bytes +max_message_size = 31457280 + # days after which mails are unconditionally deleted delete_mails_after = 20 diff --git a/chatmaild/src/chatmaild/tests/plugin.py b/chatmaild/src/chatmaild/tests/plugin.py index ee0baab2..c61fd9b1 100644 --- a/chatmaild/src/chatmaild/tests/plugin.py +++ b/chatmaild/src/chatmaild/tests/plugin.py @@ -14,10 +14,11 @@ from chatmaild.config import read_config, write_initial_config def make_config(tmp_path): inipath = tmp_path.joinpath("chatmail.ini") - def make_conf(mail_domain): + def make_conf(mail_domain, settings=None): basedir = tmp_path.joinpath(f"vmail/{mail_domain}") basedir.mkdir(parents=True, exist_ok=True) - overrides = dict(mailboxes_dir=str(basedir)) + overrides = settings.copy() if settings else {} + overrides["mailboxes_dir"] = str(basedir) write_initial_config(inipath, mail_domain, overrides=overrides) return read_config(inipath) diff --git a/chatmaild/src/chatmaild/tests/test_config.py b/chatmaild/src/chatmaild/tests/test_config.py index fa09eda7..2ab96344 100644 --- a/chatmaild/src/chatmaild/tests/test_config.py +++ b/chatmaild/src/chatmaild/tests/test_config.py @@ -58,3 +58,8 @@ def test_config_userstate_paths(make_config, tmp_path): with pytest.raises(ValueError): config.get_user(".") + + +def test_config_max_message_size(make_config, tmp_path): + config = make_config("something.testrun.org", dict(max_message_size="10000")) + assert config.max_message_size == 10000 diff --git a/cmdeploy/src/cmdeploy/dns.py b/cmdeploy/src/cmdeploy/dns.py index 38e0d9c0..7d2e9c43 100644 --- a/cmdeploy/src/cmdeploy/dns.py +++ b/cmdeploy/src/cmdeploy/dns.py @@ -15,7 +15,7 @@ def get_initial_remote_data(sshexec, mail_domain): def check_initial_remote_data(remote_data, print=print): mail_domain = remote_data["mail_domain"] if not remote_data["A"] and not remote_data["AAAA"]: - print("Missing A and/or AAAA DNS records for {mail_domain}!") + print(f"Missing A and/or AAAA DNS records for {mail_domain}!") elif not remote_data["MTA_STS"]: print("Missing MTA-STS CNAME record:") print(f"mta-sts.{mail_domain}. CNAME {mail_domain}") diff --git a/cmdeploy/src/cmdeploy/postfix/main.cf.j2 b/cmdeploy/src/cmdeploy/postfix/main.cf.j2 index aacf85cf..cfa95cfc 100644 --- a/cmdeploy/src/cmdeploy/postfix/main.cf.j2 +++ b/cmdeploy/src/cmdeploy/postfix/main.cf.j2 @@ -62,8 +62,7 @@ mydestination = relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 -# maximum 30MB sized messages -message_size_limit = 31457280 +message_size_limit = {{config.max_message_size}} recipient_delimiter = + inet_interfaces = all inet_protocols = all